lint-staged 16.2.3 → 16.2.5
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/getSpawnedTask.js +19 -7
- package/lib/loadConfig.js +1 -3
- package/package.json +10 -10
package/lib/getSpawnedTask.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spawn from 'nano-spawn'
|
|
1
|
+
import spawn, { SubprocessError } from 'nano-spawn'
|
|
2
2
|
import pidtree from 'pidtree'
|
|
3
3
|
import { parseArgsStringToArgv } from 'string-argv'
|
|
4
4
|
|
|
@@ -30,11 +30,17 @@ const handleOutput = (command, result, ctx, isError = false) => {
|
|
|
30
30
|
const outputTitle = isError ? red(`${error} ${command}:`) : `${info} ${command}:`
|
|
31
31
|
const output = [...(ctx.quiet ? [] : ['', outputTitle]), result.output]
|
|
32
32
|
ctx.output.push(output.join('\n'))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (ctx.quiet) return
|
|
36
|
+
|
|
37
|
+
if (result instanceof SubprocessError) {
|
|
38
|
+
ctx.output.push(red(`\n${error} ${command} failed to spawn:`), result.message, result.cause)
|
|
33
39
|
} else if (isError) {
|
|
34
40
|
// Show generic error when task had no output
|
|
35
41
|
const tag = getTag(result)
|
|
36
42
|
const message = red(`\n${error} ${command} failed without output (${tag}).`)
|
|
37
|
-
|
|
43
|
+
ctx.output.push(message)
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
|
|
@@ -43,7 +49,13 @@ const handleOutput = (command, result, ctx, isError = false) => {
|
|
|
43
49
|
* @param {import('nano-spawn').Subprocess} subprocess
|
|
44
50
|
*/
|
|
45
51
|
const killSubprocess = async (subprocess) => {
|
|
46
|
-
|
|
52
|
+
let childProcess
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
childProcess = await subprocess.nodeChildProcess
|
|
56
|
+
} catch {
|
|
57
|
+
/** ignore internal nano-spawn errors, if child process isn't available it can't be killed */
|
|
58
|
+
}
|
|
47
59
|
|
|
48
60
|
if (childProcess?.pid !== undefined) {
|
|
49
61
|
try {
|
|
@@ -62,7 +74,7 @@ const killSubprocess = async (subprocess) => {
|
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
// The child process is terminated separately in order to get the `KILLED` status.
|
|
65
|
-
childProcess
|
|
77
|
+
childProcess?.kill('SIGKILL')
|
|
66
78
|
}
|
|
67
79
|
|
|
68
80
|
/**
|
|
@@ -149,11 +161,11 @@ export const getSpawnedTask = ({
|
|
|
149
161
|
debugLog('Spawn options:', spawnOptions)
|
|
150
162
|
|
|
151
163
|
return async (ctx = getInitialState()) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const quitInterruptCheck = interruptExecutionOnError(ctx, subprocess)
|
|
164
|
+
let quitInterruptCheck
|
|
155
165
|
|
|
156
166
|
try {
|
|
167
|
+
const subprocess = spawn(cmd, isFn ? args : args.concat(files), spawnOptions)
|
|
168
|
+
quitInterruptCheck = interruptExecutionOnError(ctx, subprocess)
|
|
157
169
|
const result = await subprocess
|
|
158
170
|
if (verbose) {
|
|
159
171
|
handleOutput(command, result, ctx)
|
package/lib/loadConfig.js
CHANGED
|
@@ -4,8 +4,6 @@ import fs from 'node:fs/promises'
|
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { pathToFileURL } from 'node:url'
|
|
6
6
|
|
|
7
|
-
import YAML from 'yaml'
|
|
8
|
-
|
|
9
7
|
import { CONFIG_NAME, PACKAGE_JSON_FILE, PACKAGE_YAML_FILES } from './configFiles.js'
|
|
10
8
|
import { createDebug } from './debug.js'
|
|
11
9
|
import { failedToLoadConfig } from './messages.js'
|
|
@@ -34,7 +32,7 @@ const jsonParse = async (filename) => {
|
|
|
34
32
|
const yamlParse = async (filename) => {
|
|
35
33
|
const isPackageFile = PACKAGE_YAML_FILES.includes(path.basename(filename))
|
|
36
34
|
try {
|
|
37
|
-
const content = await readFile(filename)
|
|
35
|
+
const [YAML, content] = await Promise.all([import('yaml'), readFile(filename)])
|
|
38
36
|
const yaml = YAML.parse(content)
|
|
39
37
|
return isPackageFile ? yaml[CONFIG_NAME] : yaml
|
|
40
38
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.5",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"commander": "^14.0.1",
|
|
52
52
|
"listr2": "^9.0.4",
|
|
53
53
|
"micromatch": "^4.0.8",
|
|
54
|
-
"nano-spawn": "^
|
|
54
|
+
"nano-spawn": "^2.0.0",
|
|
55
55
|
"pidtree": "^0.6.0",
|
|
56
56
|
"string-argv": "^0.3.2",
|
|
57
57
|
"yaml": "^2.8.1"
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@changesets/changelog-github": "0.5.1",
|
|
61
61
|
"@changesets/cli": "2.29.7",
|
|
62
|
-
"@commitlint/cli": "
|
|
63
|
-
"@commitlint/config-conventional": "
|
|
64
|
-
"@eslint/js": "9.
|
|
62
|
+
"@commitlint/cli": "20.1.0",
|
|
63
|
+
"@commitlint/config-conventional": "20.0.0",
|
|
64
|
+
"@eslint/js": "9.38.0",
|
|
65
65
|
"@vitest/coverage-v8": "3.2.4",
|
|
66
|
-
"@vitest/eslint-plugin": "1.3.
|
|
66
|
+
"@vitest/eslint-plugin": "1.3.23",
|
|
67
67
|
"consolemock": "1.1.0",
|
|
68
|
-
"cross-env": "10.
|
|
69
|
-
"eslint": "9.
|
|
68
|
+
"cross-env": "10.1.0",
|
|
69
|
+
"eslint": "9.38.0",
|
|
70
70
|
"eslint-config-prettier": "10.1.8",
|
|
71
71
|
"eslint-plugin-n": "17.23.1",
|
|
72
72
|
"eslint-plugin-prettier": "5.5.4",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"husky": "9.1.7",
|
|
75
75
|
"mock-stdin": "1.0.0",
|
|
76
76
|
"prettier": "3.6.2",
|
|
77
|
-
"semver": "7.7.
|
|
78
|
-
"typescript": "5.9.
|
|
77
|
+
"semver": "7.7.3",
|
|
78
|
+
"typescript": "5.9.3",
|
|
79
79
|
"vitest": "3.2.4"
|
|
80
80
|
},
|
|
81
81
|
"keywords": [
|