Skip to content

Commit c5627f8

Browse files
committed
fix: RangeError: Maximum call stack size exceeded
Closes #826
1 parent c3136ad commit c5627f8

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/asarUtil.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,22 @@ const concurrency = {concurrency: MAX_FILE_REQUESTS}
2121
const NODE_MODULES_PATTERN = path.sep + "node_modules" + path.sep
2222

2323
export async function walk(dirPath: string, consumer?: (file: string, stat: Stats) => void, filter?: Filter, addRootToResult?: boolean): Promise<Array<string>> {
24-
const list = await BluebirdPromise.map(await readdir(dirPath), name => {
25-
const filePath = dirPath + path.sep + name
26-
return lstat(filePath)
27-
.then((stat): any => {
28-
if (filter != null && !filter(filePath, stat)) {
29-
return null
30-
}
24+
const childNames = await readdir(dirPath)
25+
const list = await BluebirdPromise.map(childNames, name => lstat(dirPath + path.sep + name), concurrency)
26+
.then(stats => BluebirdPromise.map(stats, (stat, index): any => {
27+
const filePath = dirPath + path.sep + childNames[index]
28+
if (filter != null && !filter(filePath, stat)) {
29+
return null
30+
}
3131

32-
if (consumer != null) {
33-
consumer(filePath, stat)
34-
}
35-
if (stat.isDirectory()) {
36-
return walk(filePath, consumer, filter, true)
37-
}
38-
return filePath
39-
})
40-
}, concurrency)
32+
if (consumer != null) {
33+
consumer(filePath, stat)
34+
}
35+
if (stat.isDirectory()) {
36+
return walk(filePath, consumer, filter, true)
37+
}
38+
return filePath
39+
}, concurrency))
4140

4241
list.sort((a, b) => {
4342
// files before directories

0 commit comments

Comments
 (0)