lint-staged 9.4.1 → 9.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "9.4.1",
3
+ "version": "9.4.2",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",
@@ -28,15 +28,19 @@ module.exports = async function makeCmdTasks({ commands, files, gitDir, shell })
28
28
  // Create a matching command array with [file] in place of file names
29
29
  let mockCommands
30
30
  if (isFn) {
31
- const mockFileList = Array(commands.length).fill('[file]')
31
+ const mockFileList = Array(files.length).fill('[file]')
32
32
  const resolved = command(mockFileList)
33
33
  mockCommands = Array.isArray(resolved) ? resolved : [resolved]
34
34
  }
35
35
 
36
36
  commands.forEach((command, i) => {
37
- // If command is a function, use the matching mock command as title,
38
- // but since might include multiple [file] arguments, shorten to one
39
- const title = isFn ? mockCommands[i].replace(/\[file\].*\[file\]/, '[file]') : command
37
+ let title = isFn ? '[Function]' : command
38
+ if (isFn && mockCommands[i]) {
39
+ // If command is a function, use the matching mock command as title,
40
+ // but since might include multiple [file] arguments, shorten to one
41
+ title = mockCommands[i].replace(/\[file\].*\[file\]/, '[file]')
42
+ }
43
+
40
44
  const task = { title, task: resolveTaskFn({ gitDir, isFn, command, files, shell }) }
41
45
  tasks.push(task)
42
46
  })