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

Commit bbebc66

Browse files
authored
Do not set the PREFIX environment variable (#13)
* Restore npm v6 behavior with INIT_CWD This should always be set to the npm cwd, even if already in the env. Fix: npm/cli#2578 * Do not set the PREFIX environment variable Fix: npm/cli#2398
1 parent 4c6be4a commit bbebc66

File tree

2 files changed

+0
-36
lines changed

2 files changed

+0
-36
lines changed

lib/set-envs.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ const setEnvs = (config) => {
5353
list: [cliConf, envConf],
5454
} = config
5555

56-
const { DESTDIR } = env
57-
if (platform !== 'win32' && DESTDIR && globalPrefix.indexOf(DESTDIR) === 0)
58-
env.PREFIX = globalPrefix.substr(DESTDIR.length)
59-
else
60-
env.PREFIX = globalPrefix
61-
6256
env.INIT_CWD = process.cwd()
6357

6458
// if the key is the default value,

test/set-envs.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ t.test('set envs that are not defaults and not already in env', t => {
1414
INIT_CWD: cwd,
1515
EDITOR: 'vim',
1616
HOME: undefined,
17-
PREFIX: undefined,
1817
npm_execpath: require.main.filename,
1918
npm_node_execpath: execPath,
2019
}
@@ -56,7 +55,6 @@ t.test('set envs that are not defaults and not already in env, array style', t =
5655
INIT_CWD: cwd,
5756
EDITOR: 'vim',
5857
HOME: undefined,
59-
PREFIX: undefined,
6058
npm_execpath: require.main.filename,
6159
npm_node_execpath: execPath,
6260
}
@@ -95,7 +93,6 @@ t.test('set envs that are not defaults and not already in env, boolean edition',
9593
INIT_CWD: cwd,
9694
EDITOR: 'vim',
9795
HOME: undefined,
98-
PREFIX: undefined,
9996
npm_execpath: require.main.filename,
10097
npm_node_execpath: execPath,
10198
}
@@ -127,33 +124,6 @@ t.test('set envs that are not defaults and not already in env, boolean edition',
127124
t.end()
128125
})
129126

130-
t.test('set PREFIX based on DESTDIR', t => {
131-
// also, don't set editor
132-
const d = { ...defaults, editor: null }
133-
const envConf = Object.create(d)
134-
const cliConf = Object.create(envConf)
135-
const extras = {
136-
NODE,
137-
INIT_CWD: cwd,
138-
HOME: undefined,
139-
PREFIX: '/usr/local',
140-
DESTDIR: '/some/dest',
141-
npm_execpath: require.main.filename,
142-
npm_node_execpath: execPath,
143-
}
144-
const env = { DESTDIR: '/some/dest' }
145-
const config = {
146-
list: [cliConf, envConf],
147-
env,
148-
defaults: d,
149-
globalPrefix: '/some/dest/usr/local',
150-
execPath,
151-
}
152-
setEnvs(config)
153-
t.strictSame(env, { ...extras })
154-
t.end()
155-
})
156-
157127
t.test('dont set npm_execpath if require.main.filename is not set', t => {
158128
const { filename } = require.main
159129
t.teardown(() => require.main.filename = filename)

0 commit comments

Comments
 (0)