lint-staged 12.1.4 → 12.1.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.
@@ -44,10 +44,13 @@ cmdline
44
44
  )
45
45
  .parse(process.argv)
46
46
 
47
- const debugLog = debug('lint-staged:bin')
48
- if (cmdline.debug) {
47
+ const cmdlineOptions = cmdline.opts()
48
+
49
+ if (cmdlineOptions.debug) {
49
50
  debug.enable('lint-staged*')
50
51
  }
52
+
53
+ const debugLog = debug('lint-staged:bin')
51
54
  debugLog('Running `lint-staged@%s`', version)
52
55
 
53
56
  /**
@@ -68,8 +71,6 @@ const getMaxArgLength = () => {
68
71
  }
69
72
  }
70
73
 
71
- const cmdlineOptions = cmdline.opts()
72
-
73
74
  const options = {
74
75
  allowEmpty: !!cmdlineOptions.allowEmpty,
75
76
  concurrent: JSON.parse(cmdlineOptions.concurrent),
package/lib/index.js CHANGED
@@ -58,7 +58,7 @@ const lintStaged = async (
58
58
  ) => {
59
59
  await validateOptions({ shell }, logger)
60
60
 
61
- const inputConfig = configObject || (await loadConfig(configPath, logger))
61
+ const inputConfig = configObject || (await loadConfig({ configPath, cwd }, logger))
62
62
 
63
63
  if (!inputConfig) {
64
64
  logger.error(`${ConfigNotFoundError.message}.`)
package/lib/loadConfig.js CHANGED
@@ -1,3 +1,5 @@
1
+ /** @typedef {import('./index').Logger} Logger */
2
+
1
3
  import { pathToFileURL } from 'url'
2
4
 
3
5
  import debug from 'debug'
@@ -56,20 +58,23 @@ const resolveConfig = (configPath) => {
56
58
  }
57
59
 
58
60
  /**
59
- * @param {string} [configPath]
60
- * @param {Logger} [logger]
61
+ * @param {object} options
62
+ * @param {string} [options.configPath] - Explicit path to a config file
63
+ * @param {string} [options.cwd] - Current working directory
61
64
  */
62
- export const loadConfig = async (configPath, logger) => {
65
+ export const loadConfig = async ({ configPath, cwd }, logger) => {
63
66
  try {
64
67
  if (configPath) {
65
68
  debugLog('Loading configuration from `%s`...', configPath)
66
69
  } else {
67
- debugLog('Searching for configuration...')
70
+ debugLog('Searching for configuration from `%s`...', cwd)
68
71
  }
69
72
 
70
73
  const explorer = lilconfig('lint-staged', { searchPlaces, loaders })
71
74
 
72
- const result = await (configPath ? explorer.load(resolveConfig(configPath)) : explorer.search())
75
+ const result = await (configPath
76
+ ? explorer.load(resolveConfig(configPath))
77
+ : explorer.search(cwd))
73
78
  if (!result) return null
74
79
 
75
80
  // config is a promise when using the `dynamicImport` loader
@@ -79,7 +84,7 @@ export const loadConfig = async (configPath, logger) => {
79
84
 
80
85
  return config
81
86
  } catch (error) {
82
- debugLog('Failed to load configuration from `%s`', configPath)
87
+ debugLog('Failed to load configuration!')
83
88
  logger.error(error)
84
89
  return null
85
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lint-staged",
3
- "version": "12.1.4",
3
+ "version": "12.1.5",
4
4
  "description": "Lint files staged by git",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/okonet/lint-staged",