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)); var sourcePath = path.resolve(pathMap[prefix], path.relative(prefix, targetPath));
if (!fs.existsSync(sourcePath)) try {
return; var files = fs.readdirSync(sourcePath);
} catch (e) {
var files = fs if (e.code === "ENOENT") return;
.readdirSync(sourcePath) else throw e;
.filter(function(p) { }
return !excludePattern.test(p)
&& !/[\s#]/.test(p)
&& /\.js$/.test(p);
});
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")); result.push(targetPath + "/" + path.basename(p, ".js"));
}); });
} }