Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "npm run build" on Node 10 #1843

Merged
merged 1 commit into from May 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 16 additions & 12 deletions resources/fs-utils.js
Expand Up @@ -32,18 +32,22 @@ function rmdirRecursive(dirPath) {

function readdirRecursive(dirPath, opts = {}) {
const { ignoreDir } = opts;
return fs.readdirSync(dirPath, { withFileTypes: true })
.flatMap(dirent => {
const name = dirent.name;
if (dirent.isDirectory()) {
if (ignoreDir && ignoreDir.test(name)) {
return [];
}
return readdirRecursive(path.join(dirPath, name), opts)
.map(f => path.join(name, f));
}
return dirent.name;
});
const result = [];
for (const dirent of fs.readdirSync(dirPath, { withFileTypes: true })) {
const name = dirent.name;
if (!dirent.isDirectory()) {
result.push(dirent.name);
continue;
}

if (ignoreDir && ignoreDir.test(name)) {
continue;
}
const list = readdirRecursive(path.join(dirPath, name), opts)
.map(f => path.join(name, f));
result.push(...list);
}
return result;
}

function writeFile(destPath, data) {
Expand Down