Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).then(() => fs.readdir(target)).map(path => pathFn.join(target, path)).filter(path => fs.stat(path).then(stats => stats.isDirectory())).each(removeGitDir);
}
Box.prototype._readDir = function(base, fn, prefix = '') {
const { ignore } = this;
if (base && ignore) {
if (ignore.length && isMatch(base, ignore)) {
return Promise.resolve([]);
}
}
return readdir(base).map(path => stat(join(base, path)).then(stats => {
const fullpath = join(base, path);
if (stats.isDirectory()) {
return this._readDir(fullpath, fn, `${prefix + path}/`);
}
if (ignore && ignore.length && isMatch(fullpath, ignore)) {
return Promise.resolve([]);
}
return this._checkFileStatus(prefix + path).then(file => fn(file).thenReturn(file));
})).catch(err => {
if (err.cause && err.cause.code === 'ENOENT') return;
throw err;
}).reduce((files, item) => files.concat(item), []);
};
function findConfigPath(path) {
const { dir, name } = parse(path);
return fs.readdir(dir).then(files => {
const item = files.find(item => item.startsWith(name));
if (item != null) return join(dir, item);
});
}