Skip to content

Commit

Permalink
Fix "npm run build" on Node 10 (#1843)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 1, 2019
1 parent ec206fc commit 22f0719
Showing 1 changed file with 16 additions and 12 deletions.
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

0 comments on commit 22f0719

Please sign in to comment.