lint-staged 16.1.4 → 16.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/getSpawnedTask.js +16 -13
- package/lib/resolveGitRepo.js +6 -6
- package/package.json +9 -9
package/lib/getSpawnedTask.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import debug from 'debug'
|
|
3
3
|
import spawn from 'nano-spawn'
|
|
4
|
-
import
|
|
4
|
+
import pidtree from 'pidtree'
|
|
5
5
|
import { parseArgsStringToArgv } from 'string-argv'
|
|
6
6
|
|
|
7
7
|
import { error, info } from './figures.js'
|
|
@@ -45,19 +45,20 @@ const handleOutput = (command, result, ctx, isError = false) => {
|
|
|
45
45
|
const killSubprocess = async (subprocess) => {
|
|
46
46
|
const childProcess = await subprocess.nodeChildProcess
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
if (childProcess?.pid !== undefined) {
|
|
49
|
+
try {
|
|
50
|
+
for (const childPid of await pidtree(childProcess.pid)) {
|
|
51
|
+
try {
|
|
52
|
+
process.kill(childPid, 'SIGKILL')
|
|
53
|
+
} catch (error) {
|
|
54
|
+
debugLog(`Failed to kill process with pid "%d": %o`, childPid, error)
|
|
55
|
+
}
|
|
55
56
|
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
// Suppress "No matching pid found" error. This probably means
|
|
59
|
+
// the process already died before executing.
|
|
60
|
+
debugLog(`Failed to list child processes of pid "%d": %o`, childProcess.pid, error)
|
|
56
61
|
}
|
|
57
|
-
} catch (error) {
|
|
58
|
-
// Suppress "No matching pid found" error. This probably means
|
|
59
|
-
// the process already died before executing.
|
|
60
|
-
debugLog(`Failed to kill process with pid "%d": %o`, childProcess.pid, error)
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
// The child process is terminated separately in order to get the `KILLED` status.
|
|
@@ -85,7 +86,9 @@ const interruptExecutionOnError = (ctx, subprocess) => {
|
|
|
85
86
|
|
|
86
87
|
return async () => {
|
|
87
88
|
ctx.events.off(TASK_ERROR, errorListener)
|
|
88
|
-
|
|
89
|
+
if (killPromise) {
|
|
90
|
+
await killPromise
|
|
91
|
+
}
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
|
package/lib/resolveGitRepo.js
CHANGED
|
@@ -39,18 +39,18 @@ export const resolveGitRepo = async (cwd = process.cwd()) => {
|
|
|
39
39
|
try {
|
|
40
40
|
debugLog('Resolving git repo from `%s`', cwd)
|
|
41
41
|
|
|
42
|
-
/** Git rev-parse returns all three flag values on separate lines */
|
|
43
|
-
const revParseOutput = await execGit(['rev-parse', CDUP, TOPLEVEL, ABSOLUTE_GIT_DIR], {
|
|
44
|
-
cwd,
|
|
45
|
-
})
|
|
46
|
-
const [relativeTopLevelDir, topLevel, absoluteGitDir] = revParseOutput.split('\n')
|
|
47
|
-
|
|
48
42
|
// Unset GIT_DIR before running any git operations in case it's pointing to an incorrect location
|
|
49
43
|
debugLog('Unset GIT_DIR (was `%s`)', process.env.GIT_DIR)
|
|
50
44
|
delete process.env.GIT_DIR
|
|
51
45
|
debugLog('Unset GIT_WORK_TREE (was `%s`)', process.env.GIT_WORK_TREE)
|
|
52
46
|
delete process.env.GIT_WORK_TREE
|
|
53
47
|
|
|
48
|
+
/** Git rev-parse returns all three flag values on separate lines */
|
|
49
|
+
const revParseOutput = await execGit(['rev-parse', CDUP, TOPLEVEL, ABSOLUTE_GIT_DIR], {
|
|
50
|
+
cwd,
|
|
51
|
+
})
|
|
52
|
+
const [relativeTopLevelDir, topLevel, absoluteGitDir] = revParseOutput.split('\n')
|
|
53
|
+
|
|
54
54
|
const topLevelDir = normalizePath(path.join(cwd, relativeTopLevelDir))
|
|
55
55
|
debugLog('Resolved git repository top-level directory to be `%s`', topLevelDir)
|
|
56
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "16.1.
|
|
3
|
+
"version": "16.1.6",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -51,33 +51,33 @@
|
|
|
51
51
|
"tag": "npx changeset tag"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"chalk": "^5.
|
|
54
|
+
"chalk": "^5.6.0",
|
|
55
55
|
"commander": "^14.0.0",
|
|
56
56
|
"debug": "^4.4.1",
|
|
57
57
|
"lilconfig": "^3.1.3",
|
|
58
|
-
"listr2": "^9.0.
|
|
58
|
+
"listr2": "^9.0.3",
|
|
59
59
|
"micromatch": "^4.0.8",
|
|
60
60
|
"nano-spawn": "^1.0.2",
|
|
61
61
|
"pidtree": "^0.6.0",
|
|
62
62
|
"string-argv": "^0.3.2",
|
|
63
|
-
"yaml": "^2.8.
|
|
63
|
+
"yaml": "^2.8.1"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@changesets/changelog-github": "0.5.1",
|
|
67
|
-
"@changesets/cli": "2.29.
|
|
67
|
+
"@changesets/cli": "2.29.6",
|
|
68
68
|
"@commitlint/cli": "19.8.1",
|
|
69
69
|
"@commitlint/config-conventional": "19.8.1",
|
|
70
|
-
"@eslint/js": "9.
|
|
70
|
+
"@eslint/js": "9.34.0",
|
|
71
71
|
"consolemock": "1.1.0",
|
|
72
72
|
"cross-env": "10.0.0",
|
|
73
|
-
"eslint": "9.
|
|
73
|
+
"eslint": "9.34.0",
|
|
74
74
|
"eslint-config-prettier": "10.1.8",
|
|
75
75
|
"eslint-plugin-jest": "29.0.1",
|
|
76
76
|
"eslint-plugin-n": "17.21.3",
|
|
77
|
-
"eslint-plugin-prettier": "5.5.
|
|
77
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
78
78
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
79
79
|
"husky": "9.1.7",
|
|
80
|
-
"jest": "30.
|
|
80
|
+
"jest": "30.1.1",
|
|
81
81
|
"jest-snapshot-serializer-ansi": "2.2.1",
|
|
82
82
|
"mock-stdin": "1.0.0",
|
|
83
83
|
"prettier": "3.6.2",
|