Skip to content

Commit 0b8f446

Browse files
committed
fix: EMFILE: too many open files error while sigining
copied from electron#286
1 parent c6aa0f3 commit 0b8f446

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

src/util.ts

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,33 +136,32 @@ export async function walkAsync (dirPath: string): Promise<string[]> {
136136
debugLog('Walking... ' + dirPath);
137137

138138
async function _walkAsync (dirPath: string): Promise<DeepList<string>> {
139+
const res: DeepList<string> = [];
139140
const children = await fs.readdir(dirPath);
140-
return await Promise.all(
141-
children.map(async (child) => {
142-
const filePath = path.resolve(dirPath, child);
143-
144-
const stat = await fs.stat(filePath);
145-
if (stat.isFile()) {
146-
switch (path.extname(filePath)) {
147-
case '.cstemp': // Temporary file generated from past codesign
148-
debugLog('Removing... ' + filePath);
149-
await fs.remove(filePath);
150-
return null;
151-
default:
152-
return await getFilePathIfBinary(filePath);
153-
}
154-
} else if (stat.isDirectory() && !stat.isSymbolicLink()) {
155-
const walkResult = await _walkAsync(filePath);
156-
switch (path.extname(filePath)) {
157-
case '.app': // Application
158-
case '.framework': // Framework
159-
walkResult.push(filePath);
160-
}
161-
return walkResult;
141+
for (const child of children) {
142+
const filePath = path.resolve(dirPath, child);
143+
const stat = await fs.stat(filePath);
144+
if (stat.isFile()) {
145+
switch (path.extname(filePath)) {
146+
case '.cstemp': // Temporary file generated from past codesign
147+
debugLog('Removing... ' + filePath);
148+
await fs.remove(filePath);
149+
break;
150+
default:
151+
await getFilePathIfBinary(filePath) && res.push(filePath);
152+
break;
162153
}
163-
return null;
164-
})
165-
);
154+
} else if (stat.isDirectory() && !stat.isSymbolicLink()) {
155+
const walkResult = await _walkAsync(filePath);
156+
switch (path.extname(filePath)) {
157+
case '.app': // Application
158+
case '.framework': // Framework
159+
walkResult.push(filePath);
160+
}
161+
res.push(walkResult);
162+
}
163+
}
164+
return res;
166165
}
167166

168167
const allPaths = await _walkAsync(dirPath);

0 commit comments

Comments
 (0)