lint-staged 12.4.0 → 12.4.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/lib/searchConfigs.js +21 -20
- package/package.json +1 -1
package/lib/searchConfigs.js
CHANGED
|
@@ -14,7 +14,8 @@ const debugLog = debug('lint-staged:searchConfigs')
|
|
|
14
14
|
|
|
15
15
|
const EXEC_GIT = ['ls-files', '-z', '--full-name']
|
|
16
16
|
|
|
17
|
-
const filterPossibleConfigFiles = (
|
|
17
|
+
const filterPossibleConfigFiles = (files) =>
|
|
18
|
+
files.filter((file) => searchPlaces.includes(basename(file)))
|
|
18
19
|
|
|
19
20
|
const numberOfLevels = (file) => file.split('/').length
|
|
20
21
|
|
|
@@ -58,20 +59,18 @@ export const searchConfigs = async (
|
|
|
58
59
|
return { [configPath]: validateConfig(config, filepath, logger) }
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
filterPossibleConfigFiles
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
).filter(filterPossibleConfigFiles)
|
|
62
|
+
const [cachedFiles, otherFiles] = await Promise.all([
|
|
63
|
+
/** Get all possible config files known to git */
|
|
64
|
+
execGit(EXEC_GIT, { cwd: gitDir }).then(parseGitZOutput).then(filterPossibleConfigFiles),
|
|
65
|
+
/** Get all possible config files from uncommitted files */
|
|
66
|
+
execGit([...EXEC_GIT, '--others', '--exclude-standard'], { cwd: gitDir })
|
|
67
|
+
.then(parseGitZOutput)
|
|
68
|
+
.then(filterPossibleConfigFiles),
|
|
69
|
+
])
|
|
70
70
|
|
|
71
71
|
/** Sort possible config files so that deepest is first */
|
|
72
72
|
const possibleConfigFiles = [...cachedFiles, ...otherFiles]
|
|
73
|
-
.map((file) => join(gitDir, file))
|
|
74
|
-
.map((file) => normalize(file))
|
|
73
|
+
.map((file) => normalize(join(gitDir, file)))
|
|
75
74
|
.filter(isInsideDirectory(cwd))
|
|
76
75
|
.sort(sortDeepestParth)
|
|
77
76
|
|
|
@@ -85,15 +84,17 @@ export const searchConfigs = async (
|
|
|
85
84
|
|
|
86
85
|
/** Load and validate all configs to the above object */
|
|
87
86
|
await Promise.all(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
configs[filepath] = validateConfig(config, filepath, logger)
|
|
87
|
+
Object.keys(configs).map((configPath) =>
|
|
88
|
+
loadConfig({ configPath }, logger).then(({ config, filepath }) => {
|
|
89
|
+
if (config) {
|
|
90
|
+
if (configPath !== filepath) {
|
|
91
|
+
debugLog('Config file "%s" resolved to "%s"', configPath, filepath)
|
|
94
92
|
}
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
|
|
94
|
+
configs[configPath] = validateConfig(config, filepath, logger)
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
)
|
|
97
98
|
)
|
|
98
99
|
|
|
99
100
|
/** Get validated configs from the above object, without any `null` values (not found) */
|