Skip to content

Commit

Permalink
Added check if file exists before attempting to open it
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaumbach committed Aug 14, 2014
1 parent 3a2f5b2 commit eb7151a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions bin/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ exports.getJSDocumentation = function(js) {

exports.getFiles = function(dir) {
var results = [];
var list = fs.readdirSync(dir);
for (i in list) {
var file = list[i];
if (file == "node_modules" || file == "html") continue;
file = dir + '/' + file;
var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(exports.getFiles(file));
} else {
results.push(file);
if (fs.existsSync(dir)) {
var list = fs.readdirSync(dir);
for (i in list) {
var file = list[i];
if (file == "node_modules" || file == "html") continue;
file = dir + '/' + file;
var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(exports.getFiles(file));
} else {
results.push(file);
}
}
}
return results;
Expand All @@ -76,4 +78,4 @@ exports.getMarkdown = function(dir) {
}
});
return results;
}
};

0 comments on commit eb7151a

Please sign in to comment.