Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create fn title with mock file list of correct length #710

Merged
merged 2 commits into from
Oct 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/makeCmdTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ module.exports = async function makeCmdTasks({ commands, files, gitDir, shell })
// Create a matching command array with [file] in place of file names
let mockCommands
if (isFn) {
const mockFileList = Array(commands.length).fill('[file]')
const mockFileList = Array(files.length).fill('[file]')
const resolved = command(mockFileList)
mockCommands = Array.isArray(resolved) ? resolved : [resolved]
}

commands.forEach((command, i) => {
// If command is a function, use the matching mock command as title,
// but since might include multiple [file] arguments, shorten to one
const title = isFn ? mockCommands[i].replace(/\[file\].*\[file\]/, '[file]') : command
let title = isFn ? '[Function]' : command
if (isFn && mockCommands[i]) {
// If command is a function, use the matching mock command as title,
// but since might include multiple [file] arguments, shorten to one
title = mockCommands[i].replace(/\[file\].*\[file\]/, '[file]')
}

const task = { title, task: resolveTaskFn({ gitDir, isFn, command, files, shell }) }
tasks.push(task)
})
Expand Down