Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

[BUG] env of "" should be treated as null/unset #2

Closed
isaacs opened this issue Aug 25, 2020 · 1 comment
Closed

[BUG] env of "" should be treated as null/unset #2

isaacs opened this issue Aug 25, 2020 · 1 comment

Comments

@isaacs
Copy link
Contributor

isaacs commented Aug 25, 2020

$ npm_config_only= npm config get only
npm WARN invalid config only="" set in environment
npm WARN invalid config Must be one of: null, dev, development, prod, production
null

Expect:

$ npm_config_only= node ../cli-v6 get only
null
@isaacs
Copy link
Contributor Author

isaacs commented Aug 25, 2020

  loadEnv () {
    const prefix = 'npm_config_'
    const conf = Object.create(null)
    for (const [envKey, envVal] of Object.entries(this.env)) {
      if (!/^npm_config_/i.test(envKey) || envVal === '')  <-- edit this to add the check for ''
        continue
      const key = envKey.substr('npm_config_'.length)
        .replace(/(?!^)_/g, '-') // don't replace _ at the start of the key
        .toLowerCase()
      conf[key] = envVal
    }
    this[_loadObject](conf, 'env', 'environment')
  }

@isaacs isaacs closed this as completed in 3b63000 Aug 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant