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.
@@ -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 = (file) => searchPlaces.includes(basename(file))
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
- /** Get all possible config files known to git */
62
- const cachedFiles = parseGitZOutput(await execGit(EXEC_GIT, { cwd: gitDir })).filter(
63
- filterPossibleConfigFiles
64
- )
65
-
66
- /** Get all possible config files from uncommitted files */
67
- const otherFiles = parseGitZOutput(
68
- await execGit([...EXEC_GIT, '--others', '--exclude-standard'], { cwd: gitDir })
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
- possibleConfigFiles
89
- .map((configPath) => loadConfig({ configPath }, logger))
90
- .map((promise) =>
91
- promise.then(({ config, filepath }) => {
92
- if (config) {
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) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "12.4.0",
3
+ "version": "12.4.1",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",