Skip to content

Commit

Permalink
fix: .nirc may not exist (#186)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
a1mersnow and antfu authored Nov 20, 2023
1 parent 7f4ff3f commit 8812328
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,18 @@ let config: Config | undefined
export async function getConfig(): Promise<Config> {
if (!config) {
const agent = await detect({ programmatic: true })
if (agent)
if (agent) {
config = { ...defaultConfig, defaultAgent: agent }
else
config = Object.assign({}, defaultConfig, ini.parse(fs.readFileSync(rcPath, 'utf-8')))
}
else {
config = Object.assign(
{},
defaultConfig,
fs.existsSync(rcPath)
? ini.parse(fs.readFileSync(rcPath, 'utf-8'))
: null,
)
}
}

return config
Expand Down

0 comments on commit 8812328

Please sign in to comment.