Skip to content

Commit cc34997

Browse files
committed
remove npm vars from the environment
1 parent b3e3219 commit cc34997

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,28 @@ async function write (opts, pkg) {
142142
spaces: opts.spacer || 2
143143
})
144144

145+
// Remove npm env vars from the commands, this
146+
// is so it respects the directory it is run in,
147+
// otherwise this overrides things in .npmrc
148+
const env = Object.keys(shell.env).reduce((e, key) => {
149+
if (key.startsWith('npm_')) {
150+
return e
151+
}
152+
e[key] = shell.env[key]
153+
return e
154+
}, {})
155+
145156
// Run installs
146157
if (opts.dependencies && opts.dependencies.length) {
147158
await shell.exec(`npm i --save ${opts.dependencies.join(' ')}`, {
159+
env: env,
148160
cwd: opts.directory,
149161
silent: opts.silent
150162
})
151163
}
152164
if (opts.devDependencies && opts.devDependencies.length) {
153165
await shell.exec(`npm i --save-dev ${opts.devDependencies.join(' ')}`, {
166+
env: env,
154167
cwd: opts.directory,
155168
silent: opts.silent
156169
})

0 commit comments

Comments
 (0)