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

Commit 4c6be4a

Browse files
authored
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
1 parent 95d5662 commit 4c6be4a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/set-envs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const setEnvs = (config) => {
5959
else
6060
env.PREFIX = globalPrefix
6161

62-
env.INIT_CWD = env.INIT_CWD || process.cwd()
62+
env.INIT_CWD = process.cwd()
6363

6464
// if the key is the default value,
6565
// if the environ is NOT the default value,

test/set-envs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ t.test('set envs that are not defaults and not already in env, array style', t =
5353
const cliConf = Object.create(envConf)
5454
const extras = {
5555
NODE,
56-
INIT_CWD: '/some/other/path',
56+
INIT_CWD: cwd,
5757
EDITOR: 'vim',
5858
HOME: undefined,
5959
PREFIX: undefined,
6060
npm_execpath: require.main.filename,
6161
npm_node_execpath: execPath,
6262
}
63-
// make sure it's sticky
63+
// make sure it's not sticky
6464
const env = { INIT_CWD: '/some/other/path' }
6565
const config = { list: [cliConf, envConf], env, defaults, execPath }
6666
setEnvs(config)

0 commit comments

Comments
 (0)