Permalink
Browse files

Add check for file existence when parsing paths (fixes issue with bro…

…ken symbolic links)
  • Loading branch information...
1 parent 481121d commit dcaf9ef328b0e12865f50c4b7d56c7a5d2bc9d71 @Asuza Asuza committed May 19, 2014
Showing with 35 additions and 29 deletions.
  1. +35 −29 src/LintRoller.js
View
@@ -335,38 +335,44 @@ var LintRoller = {
*/
parseFile : function (currPath, fileName) {
var spacer = ' ',
- childPath;
-
- var stats = this.fs.statSync(currPath + fileName);
-
- if (stats.isFile()) {
- this.log(spacer + fileName + ' IS A FILE');
- /*
- * We only want files matching our regex
- */
- if (this.regex.test(fileName)) {
- this.files.push(currPath + fileName);
- this.log(spacer + 'Added to the list.');
- }
- else {
- this.log(spacer + fileName + ' IS NOT A MATCHING FILE');
- }
- }
- else {
- this.log(spacer + fileName + ' IS NOT A FILE');
-
- /*
- * If not a file
- * - check against parent paths
- * - recurse into child paths
- */
- if (fileName === '.' || fileName === '..') {
- this.log(spacer + fileName + ' IS A RELATIVE DIRECTORY PATH');
+ filePath = currPath + fileName,
+ childPath,
+ stats;
+
+ if (this.fs.existsSync(filePath)) {
+ stats = this.fs.statSync(filePath);
+
+ if (stats.isFile()) {
+ this.log(spacer + fileName + ' IS A FILE');
+ /*
+ * We only want files matching our regex
+ */
+ if (this.regex.test(fileName)) {
+ this.files.push(filePath);
+ this.log(spacer + 'Added to the list.');
+ }
+ else {
+ this.log(spacer + fileName + ' IS NOT A MATCHING FILE');
+ }
}
else {
- childPath = currPath + fileName + '/';
- this.parseTree(childPath);
+ this.log(spacer + fileName + ' IS NOT A FILE');
+
+ /*
+ * If not a file
+ * - check against parent paths
+ * - recurse into child paths
+ */
+ if (fileName === '.' || fileName === '..') {
+ this.log(spacer + fileName + ' IS A RELATIVE DIRECTORY PATH');
+ }
+ else {
+ childPath = filePath + '/';
+ this.parseTree(childPath);
+ }
}
+ } else {
+ this.log(spacer + fileName + ' IS NOT AN EXISTING FILE');
}
},

0 comments on commit dcaf9ef

Please sign in to comment.