Skip to content

Commit

Permalink
fix: await for dynamic import promise when loading JS config
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Nov 21, 2021
1 parent dc79216 commit e96b6d9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/loadConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ const resolveConfig = (configPath) => {
/**
* @param {string} [configPath]
*/
export const loadConfig = (configPath) => {
export const loadConfig = async (configPath) => {
const explorer = lilconfig('lint-staged', { searchPlaces, loaders })
return configPath ? explorer.load(resolveConfig(configPath)) : explorer.search()
const result = await (configPath ? explorer.load(resolveConfig(configPath)) : explorer.search())
if (!result) return null

const { config, filepath } = result

// config is a promise when using the `dynamicImport` loader
return { config: await config, filepath }
}

0 comments on commit e96b6d9

Please sign in to comment.