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

Commit

Permalink
Restore npm v6 behavior with INIT_CWD (#12)
Browse files Browse the repository at this point in the history
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 4c6be4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/set-envs.js
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/set-envs.js
Expand Up @@ -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)
Expand Down

0 comments on commit 4c6be4a

Please sign in to comment.