diff --git a/lib/runAll.js b/lib/runAll.js index 9c2556036..dfe7997c1 100644 --- a/lib/runAll.js +++ b/lib/runAll.js @@ -142,52 +142,51 @@ export const runAll = async ( } for (const [index, files] of stagedFileChunks.entries()) { - const chunkTasks = generateTasks({ config, cwd, files, relative }) - const chunkListrTasks = [] - - for (const task of chunkTasks) { - const subTasks = await makeCmdTasks({ - commands: task.commands, - cwd, - files: task.fileList, - gitDir, - renderer: listrOptions.renderer, - shell, - verbose, - }) - - // Add files from task to match set - task.fileList.forEach((file) => { - matchedFiles.add(file) - }) - - hasDeprecatedGitAdd = - hasDeprecatedGitAdd || subTasks.some((subTask) => subTask.command === 'git add') - - const fileCount = task.fileList.length - - chunkListrTasks.push({ - title: `${task.pattern}${dim(` — ${fileCount} ${fileCount > 1 ? 'files' : 'file'}`)}`, - task: async () => - new Listr(subTasks, { - // In sub-tasks we don't want to run concurrently - // and we want to abort on errors - ...listrOptions, - concurrent: false, - exitOnError: true, - }), - skip: () => { - // Skip task when no files matched - if (fileCount === 0) { - return `${task.pattern}${dim(' — no files')}` - } - return false - }, - }) - } - const relativeConfig = normalize(path.relative(cwd, configPath)) + const chunkListrTasks = await Promise.all( + generateTasks({ config, cwd, files, relative }).map((task) => + makeCmdTasks({ + commands: task.commands, + cwd, + files: task.fileList, + gitDir, + renderer: listrOptions.renderer, + shell, + verbose, + }).then((subTasks) => { + // Add files from task to match set + task.fileList.forEach((file) => { + matchedFiles.add(file) + }) + + hasDeprecatedGitAdd = + hasDeprecatedGitAdd || subTasks.some((subTask) => subTask.command === 'git add') + + const fileCount = task.fileList.length + + return { + title: `${task.pattern}${dim(` — ${fileCount} ${fileCount > 1 ? 'files' : 'file'}`)}`, + task: async () => + new Listr(subTasks, { + // In sub-tasks we don't want to run concurrently + // and we want to abort on errors + ...listrOptions, + concurrent: false, + exitOnError: true, + }), + skip: () => { + // Skip task when no files matched + if (fileCount === 0) { + return `${task.pattern}${dim(' — no files')}` + } + return false + }, + } + }) + ) + ) + listrTasks.push({ title: `${relativeConfig}${dim(` — ${files.length} ${files.length > 1 ? 'files' : 'file'}`)}` +