Skip to content

Commit 142a46d

Browse files
committed
dont throw if no configuration file was found
1 parent 7d17f9f commit 142a46d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/utils.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,17 @@ function getConfig(configPath, searchPath = process.cwd(), stopDir = homedir())
124124
const configPathAbsolute = useCustomPath && path.join(process.cwd(), configPath)
125125
// search from the root of the process if the user didnt specify a config file,
126126
// or use the custom path if a file is passed.
127-
const { config, filepath } = explorer.load(searchPathAbsolute, configPathAbsolute)
128-
return { ...(config || {}), filepath }
127+
const result = explorer.load(searchPathAbsolute, configPathAbsolute)
128+
129+
// dont throw if the explorer didnt find a configfile,
130+
// instead use default config
131+
const config = result ? result.config : {}
132+
const filepath = result ? result.filepath : {}
133+
if (!result) Logger.log('No config file detected, using defaults.')
134+
135+
return { ...config, filepath }
129136
} catch (error) {
130-
Logger.error('Bad config file, Please check config file syntax')
137+
Logger.error('An error occured while parsing your config file. Using defaults...\n\n', error.message)
131138
}
132139
return {}
133140
}

0 commit comments

Comments
 (0)