lint-staged 12.1.5 → 12.1.6
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/lib/makeCmdTasks.js +3 -2
- package/lib/resolveTaskFn.js +8 -7
- package/lib/runAll.js +1 -0
- package/package.json +1 -1
package/lib/makeCmdTasks.js
CHANGED
|
@@ -28,13 +28,14 @@ const getTitleLength = (renderer, columns = process.stdout.columns) => {
|
|
|
28
28
|
*
|
|
29
29
|
* @param {object} options
|
|
30
30
|
* @param {Array<string|Function>|string|Function} options.commands
|
|
31
|
+
* @param {string} options.cwd
|
|
31
32
|
* @param {Array<string>} options.files
|
|
32
33
|
* @param {string} options.gitDir
|
|
33
34
|
* @param {string} options.renderer
|
|
34
35
|
* @param {Boolean} shell
|
|
35
36
|
* @param {Boolean} verbose
|
|
36
37
|
*/
|
|
37
|
-
export const makeCmdTasks = async ({ commands, files, gitDir, renderer, shell, verbose }) => {
|
|
38
|
+
export const makeCmdTasks = async ({ commands, cwd, files, gitDir, renderer, shell, verbose }) => {
|
|
38
39
|
debugLog('Creating listr tasks for commands %o', commands)
|
|
39
40
|
const commandArray = Array.isArray(commands) ? commands : [commands]
|
|
40
41
|
const cmdTasks = []
|
|
@@ -61,7 +62,7 @@ export const makeCmdTasks = async ({ commands, files, gitDir, renderer, shell, v
|
|
|
61
62
|
|
|
62
63
|
// Truncate title to single line based on renderer
|
|
63
64
|
const title = cliTruncate(command, getTitleLength(renderer))
|
|
64
|
-
const task = resolveTaskFn({ command, files, gitDir, isFn, shell, verbose })
|
|
65
|
+
const task = resolveTaskFn({ command, cwd, files, gitDir, isFn, shell, verbose })
|
|
65
66
|
cmdTasks.push({ title, command, task })
|
|
66
67
|
}
|
|
67
68
|
}
|
package/lib/resolveTaskFn.js
CHANGED
|
@@ -68,20 +68,20 @@ const makeErr = (command, result, ctx) => {
|
|
|
68
68
|
*
|
|
69
69
|
* @param {Object} options
|
|
70
70
|
* @param {string} options.command — Linter task
|
|
71
|
+
* @param {string} [options.cwd]
|
|
71
72
|
* @param {String} options.gitDir - Current git repo path
|
|
72
73
|
* @param {Boolean} options.isFn - Whether the linter task is a function
|
|
73
74
|
* @param {Array<string>} options.files — Filepaths to run the linter task against
|
|
74
|
-
* @param {Boolean} [options.relative] — Whether the filepaths should be relative
|
|
75
75
|
* @param {Boolean} [options.shell] — Whether to skip parsing linter task for better shell support
|
|
76
76
|
* @param {Boolean} [options.verbose] — Always show task verbose
|
|
77
77
|
* @returns {function(): Promise<Array<string>>}
|
|
78
78
|
*/
|
|
79
79
|
export const resolveTaskFn = ({
|
|
80
80
|
command,
|
|
81
|
+
cwd = process.cwd(),
|
|
81
82
|
files,
|
|
82
83
|
gitDir,
|
|
83
84
|
isFn,
|
|
84
|
-
relative,
|
|
85
85
|
shell = false,
|
|
86
86
|
verbose = false,
|
|
87
87
|
}) => {
|
|
@@ -89,14 +89,15 @@ export const resolveTaskFn = ({
|
|
|
89
89
|
debugLog('cmd:', cmd)
|
|
90
90
|
debugLog('args:', args)
|
|
91
91
|
|
|
92
|
-
const execaOptions = {
|
|
93
|
-
if (relative) {
|
|
94
|
-
execaOptions.cwd = process.cwd()
|
|
95
|
-
} else if (/^git(\.exe)?/i.test(cmd) && gitDir !== process.cwd()) {
|
|
92
|
+
const execaOptions = {
|
|
96
93
|
// Only use gitDir as CWD if we are using the git binary
|
|
97
94
|
// e.g `npm` should run tasks in the actual CWD
|
|
98
|
-
|
|
95
|
+
cwd: /^git(\.exe)?/i.test(cmd) ? gitDir : cwd,
|
|
96
|
+
preferLocal: true,
|
|
97
|
+
reject: false,
|
|
98
|
+
shell,
|
|
99
99
|
}
|
|
100
|
+
|
|
100
101
|
debugLog('execaOptions:', execaOptions)
|
|
101
102
|
|
|
102
103
|
return async (ctx = getInitialState()) => {
|
package/lib/runAll.js
CHANGED