Do not use fs.exists and handle error instead

pull/43/merge
Alex Brausewetter 2015-05-15 11:05:48 +00:00
rodzic 1a397a4a72
commit d74f1949b8
1 zmienionych plików z 13 dodań i 11 usunięć

Wyświetl plik

@ -186,18 +186,20 @@ define(function(require, exports, module) {
var sourcePath = path.resolve(pathMap[prefix], path.relative(prefix, targetPath));
if (!fs.existsSync(sourcePath))
return;
var files = fs
.readdirSync(sourcePath)
.filter(function(p) {
return !excludePattern.test(p)
&& !/[\s#]/.test(p)
&& /\.js$/.test(p);
});
try {
var files = fs.readdirSync(sourcePath);
} catch (e) {
if (e.code === "ENOENT") return;
else throw e;
}
files.map(function(p) {
files = files.filter(function(p) {
return !excludePattern.test(p)
&& !/[\s#]/.test(p)
&& /\.js$/.test(p);
});
files.forEach(function(p) {
result.push(targetPath + "/" + path.basename(p, ".js"));
});
}