Skip to content

Commit

Permalink
fix: run task command on files deep copy
Browse files Browse the repository at this point in the history
  • Loading branch information
louneskmt committed Sep 14, 2022
1 parent 17c51af commit 919cc48
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/makeCmdTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export const makeCmdTasks = async ({ commands, cwd, files, gitDir, renderer, she
debugLog('Creating listr tasks for commands %o', commands)
const commandArray = Array.isArray(commands) ? commands : [commands]
const cmdTasks = []
const filesCopy = new Array(files)

for (const cmd of commandArray) {
// command function may return array of commands that already include `stagedFiles`
const isFn = typeof cmd === 'function'
const resolved = isFn ? await cmd(files) : cmd
const resolved = isFn ? await cmd(filesCopy) : cmd

const resolvedArray = Array.isArray(resolved) ? resolved : [resolved] // Wrap non-array command as array

Expand All @@ -62,7 +63,7 @@ export const makeCmdTasks = async ({ commands, cwd, files, gitDir, renderer, she

// Truncate title to single line based on renderer
const title = cliTruncate(command, getTitleLength(renderer))
const task = resolveTaskFn({ command, cwd, files, gitDir, isFn, shell, verbose })
const task = resolveTaskFn({ command, cwd, filesCopy, gitDir, isFn, shell, verbose })
cmdTasks.push({ title, command, task })
}
}
Expand Down

0 comments on commit 919cc48

Please sign in to comment.