antfu-collective / ni

💡 Use the right package manager
MIT License
6.41k stars 209 forks source link

Is globalAgent always use npm when run 'ni -g xxx' in project workspace? #183

Closed aswind7 closed 11 months ago

aswind7 commented 11 months ago

when i run 'ni -g xxx' in a project workspace i see it always use npm, then i see the source code of src/config.ts. I think it always excute config = { ...defaultConfig, defaultAgent: agent } because agent always exists. And i want to know is it so? thanks.

export async function getConfig(): Promise<Config> {
  if (!config) {
    const agent = await detect({ programmatic: true })
    if (agent)
      config = { ...defaultConfig, defaultAgent: agent }
    else
      config = Object.assign({}, defaultConfig, ini.parse(fs.readFileSync(rcPath, 'utf-8')))
  }

  return config
}
antfu commented 11 months ago
image image