lint-staged 13.3.0 → 14.0.1
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/bin/lint-staged.js +5 -8
- package/lib/messages.js +1 -1
- package/lib/readStdin.js +19 -0
- package/package.json +2 -1
package/bin/lint-staged.js
CHANGED
|
@@ -8,6 +8,7 @@ import debug from 'debug'
|
|
|
8
8
|
|
|
9
9
|
import lintStaged from '../lib/index.js'
|
|
10
10
|
import { CONFIG_STDIN_ERROR } from '../lib/messages.js'
|
|
11
|
+
import { readStdin } from '../lib/readStdin.js'
|
|
11
12
|
|
|
12
13
|
// Force colors for packages that depend on https://www.npmjs.com/package/supports-color
|
|
13
14
|
if (supportsColor) {
|
|
@@ -110,17 +111,13 @@ debugLog('Options parsed from command-line:', options)
|
|
|
110
111
|
if (options.configPath === '-') {
|
|
111
112
|
delete options.configPath
|
|
112
113
|
try {
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
debugLog('Reading config from stdin')
|
|
115
|
+
options.config = JSON.parse(await readStdin())
|
|
116
|
+
} catch (error) {
|
|
117
|
+
debugLog(CONFIG_STDIN_ERROR, error)
|
|
115
118
|
console.error(CONFIG_STDIN_ERROR)
|
|
116
119
|
process.exit(1)
|
|
117
120
|
}
|
|
118
|
-
|
|
119
|
-
try {
|
|
120
|
-
options.config = JSON.parse(options.config)
|
|
121
|
-
} catch {
|
|
122
|
-
// Let config parsing complain if it's not JSON
|
|
123
|
-
}
|
|
124
121
|
}
|
|
125
122
|
|
|
126
123
|
try {
|
package/lib/messages.js
CHANGED
|
@@ -71,4 +71,4 @@ export const RESTORE_STASH_EXAMPLE = ` Any lost modifications can be restored f
|
|
|
71
71
|
> git stash apply --index stash@{0}
|
|
72
72
|
`
|
|
73
73
|
|
|
74
|
-
export const CONFIG_STDIN_ERROR =
|
|
74
|
+
export const CONFIG_STDIN_ERROR = chalk.redBright(`${error} Failed to read config from stdin.`)
|
package/lib/readStdin.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a promise resolving to the first line written to stdin after invoking.
|
|
5
|
+
* @warn will never resolve if called after writing to stdin
|
|
6
|
+
*
|
|
7
|
+
* @returns {Promise<string>}
|
|
8
|
+
*/
|
|
9
|
+
export const readStdin = () => {
|
|
10
|
+
const readline = createInterface({ input: process.stdin })
|
|
11
|
+
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
readline.prompt()
|
|
14
|
+
readline.on('line', (line) => {
|
|
15
|
+
readline.close()
|
|
16
|
+
resolve(line)
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lint-staged",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"description": "Lint files staged by git",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/okonet/lint-staged",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"husky": "8.0.3",
|
|
60
60
|
"jest": "29.6.2",
|
|
61
61
|
"jest-snapshot-serializer-ansi": "2.1.0",
|
|
62
|
+
"mock-stdin": "1.0.0",
|
|
62
63
|
"prettier": "3.0.1"
|
|
63
64
|
},
|
|
64
65
|
"keywords": [
|