From e96b6d9674f07b4686876cb40605274577925973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20J=C3=A4ppinen?= Date: Sun, 21 Nov 2021 17:31:47 +0200 Subject: [PATCH] fix: await for dynamic import promise when loading JS config --- lib/loadConfig.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/loadConfig.js b/lib/loadConfig.js index b28ac8a9d..2ee43e0f5 100644 --- a/lib/loadConfig.js +++ b/lib/loadConfig.js @@ -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 } }