Skip to content

Commit 22f0719

Browse files
Fix "npm run build" on Node 10 (#1843)
1 parent ec206fc commit 22f0719

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

resources/fs-utils.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,22 @@ function rmdirRecursive(dirPath) {
3232

3333
function readdirRecursive(dirPath, opts = {}) {
3434
const { ignoreDir } = opts;
35-
return fs.readdirSync(dirPath, { withFileTypes: true })
36-
.flatMap(dirent => {
37-
const name = dirent.name;
38-
if (dirent.isDirectory()) {
39-
if (ignoreDir && ignoreDir.test(name)) {
40-
return [];
41-
}
42-
return readdirRecursive(path.join(dirPath, name), opts)
43-
.map(f => path.join(name, f));
44-
}
45-
return dirent.name;
46-
});
35+
const result = [];
36+
for (const dirent of fs.readdirSync(dirPath, { withFileTypes: true })) {
37+
const name = dirent.name;
38+
if (!dirent.isDirectory()) {
39+
result.push(dirent.name);
40+
continue;
41+
}
42+
43+
if (ignoreDir && ignoreDir.test(name)) {
44+
continue;
45+
}
46+
const list = readdirRecursive(path.join(dirPath, name), opts)
47+
.map(f => path.join(name, f));
48+
result.push(...list);
49+
}
50+
return result;
4751
}
4852

4953
function writeFile(destPath, data) {

0 commit comments

Comments
 (0)