fix(medusa-core-utils): getConfigFile typings (#2783)

* fix: getConfigFile typeings

* Create brave-apes-carry.md

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Adrien de Peretti
2022-12-14 19:35:16 +01:00
committed by GitHub
co-authored by Oliver Windall Juhl
parent 7d28eaf8c6
commit 7cced6006a
3 changed files with 13 additions and 11 deletions
@@ -9,21 +9,20 @@ import { join } from "path"
function getConfigFile<TConfig = unknown>(
rootDir: string,
configName: string
): { configModule: TConfig; configFilePath: string } | { error: any } {
): { configModule: TConfig; configFilePath: string, error?: any } {
const configPath = join(rootDir, configName)
let configFilePath = ``
let configModule
let err
try {
configFilePath = require.resolve(configPath)
configModule = require(configFilePath)
} catch (err) {
return {
error: err,
}
} catch (e) {
err = e
}
return { configModule, configFilePath }
return { configModule, configFilePath, error: err }
}
export default getConfigFile