Skip to content

Commit e96b6d9

Browse files
committedNov 21, 2021
fix: await for dynamic import promise when loading JS config
1 parent dc79216 commit e96b6d9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎lib/loadConfig.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ const resolveConfig = (configPath) => {
5757
/**
5858
* @param {string} [configPath]
5959
*/
60-
export const loadConfig = (configPath) => {
60+
export const loadConfig = async (configPath) => {
6161
const explorer = lilconfig('lint-staged', { searchPlaces, loaders })
62-
return configPath ? explorer.load(resolveConfig(configPath)) : explorer.search()
62+
const result = await (configPath ? explorer.load(resolveConfig(configPath)) : explorer.search())
63+
if (!result) return null
64+
65+
const { config, filepath } = result
66+
67+
// config is a promise when using the `dynamicImport` loader
68+
return { config: await config, filepath }
6369
}

0 commit comments

Comments
 (0)
Please sign in to comment.