Skip to content
Permalink
Browse files
Restore npm v6 behavior with INIT_CWD (#12)
This should always be set to the npm cwd, even if already in the env.

Fix: npm/cli#2578
  • Loading branch information
isaacs committed Feb 2, 2021
1 parent 95d5662 commit 4c6be4a66a3e89ae607e08172b8543b588a95fb5
Showing with 3 additions and 3 deletions.
  1. +1 −1 lib/set-envs.js
  2. +2 −2 test/set-envs.js
@@ -59,7 +59,7 @@ const setEnvs = (config) => {
else
env.PREFIX = globalPrefix

env.INIT_CWD = env.INIT_CWD || process.cwd()
env.INIT_CWD = process.cwd()

// if the key is the default value,
// if the environ is NOT the default value,
@@ -53,14 +53,14 @@ t.test('set envs that are not defaults and not already in env, array style', t =
const cliConf = Object.create(envConf)
const extras = {
NODE,
INIT_CWD: '/some/other/path',
INIT_CWD: cwd,
EDITOR: 'vim',
HOME: undefined,
PREFIX: undefined,
npm_execpath: require.main.filename,
npm_node_execpath: execPath,
}
// make sure it's sticky
// make sure it's not sticky
const env = { INIT_CWD: '/some/other/path' }
const config = { list: [cliConf, envConf], env, defaults, execPath }
setEnvs(config)

0 comments on commit 4c6be4a

Please sign in to comment.