From 72e6e61970b9186e198716d8b4e8866ea8487c53 Mon Sep 17 00:00:00 2001 From: Andre Cruz Date: Sat, 17 Aug 2013 22:39:59 +0100 Subject: [PATCH] Close GH-795: Ignore file symlinks when reading project, fixes #791 and #783.. Fixes #791, Fixes #783 --- lib/core/Project.js | 5 +++++ lib/util/validLink.js | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/core/Project.js b/lib/core/Project.js index a5617e0b..a86f7f44 100644 --- a/lib/core/Project.js +++ b/lib/core/Project.js @@ -638,6 +638,11 @@ Project.prototype._readLinks = function () { return; } + // Skip links to files (see #783) + if (!valid.isDirectory()) { + return; + } + name = path.basename(dir); return readJson(dir, { assume: { name: name } diff --git a/lib/util/validLink.js b/lib/util/validLink.js index b510cb3c..a4a591fe 100644 --- a/lib/util/validLink.js +++ b/lib/util/validLink.js @@ -2,16 +2,17 @@ var Q = require('q'); var fs = require('graceful-fs'); function validLink(file) { - // Filter only those that are valid links + // Ensures that a file is a symlink that points + // to a valid file return Q.nfcall(fs.lstat, file) .then(function (stat) { if (!stat.isSymbolicLink()) { - return [false, null]; + return [false]; } return Q.nfcall(fs.stat, file) .then(function () { - return [true, null]; + return [stat]; }); }) .fail(function (err) {