File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 } )
You can’t perform that action at this time.
0 commit comments