mirror of
https://github.com/linuxserver/core.git
synced 2026-02-20 05:07:19 +08:00
Do not use fs.exists and handle error instead
This commit is contained in:
parent
1a397a4a72
commit
d74f1949b8
@ -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"));
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user