diff --git a/src/util.ts b/src/util.ts index 9a7e5c4..3e8e9f1 100644 --- a/src/util.ts +++ b/src/util.ts @@ -136,33 +136,32 @@ export async function walkAsync (dirPath: string): Promise { debugLog('Walking... ' + dirPath); async function _walkAsync (dirPath: string): Promise> { + const res: DeepList = []; const children = await fs.readdir(dirPath); - return await Promise.all( - children.map(async (child) => { - const filePath = path.resolve(dirPath, child); - - const stat = await fs.stat(filePath); - if (stat.isFile()) { - switch (path.extname(filePath)) { - case '.cstemp': // Temporary file generated from past codesign - debugLog('Removing... ' + filePath); - await fs.remove(filePath); - return null; - default: - return await getFilePathIfBinary(filePath); - } - } else if (stat.isDirectory() && !stat.isSymbolicLink()) { - const walkResult = await _walkAsync(filePath); - switch (path.extname(filePath)) { - case '.app': // Application - case '.framework': // Framework - walkResult.push(filePath); - } - return walkResult; + for (const child of children) { + const filePath = path.resolve(dirPath, child); + const stat = await fs.stat(filePath); + if (stat.isFile()) { + switch (path.extname(filePath)) { + case '.cstemp': // Temporary file generated from past codesign + debugLog('Removing... ' + filePath); + await fs.remove(filePath); + break; + default: + await getFilePathIfBinary(filePath) && res.push(filePath); + break; } - return null; - }) - ); + } else if (stat.isDirectory() && !stat.isSymbolicLink()) { + const walkResult = await _walkAsync(filePath); + switch (path.extname(filePath)) { + case '.app': // Application + case '.framework': // Framework + walkResult.push(filePath); + } + res.push(walkResult); + } + } + return res; } const allPaths = await _walkAsync(dirPath);