@@ -33,11 +33,22 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
33
33
let stdout = '' ;
34
34
let stderr = '' ;
35
35
const cwd = options . cwd ?? process . cwd ( ) ;
36
- const env = options . env ;
36
+ const env = options . env ?? process . env ;
37
37
console . log (
38
38
`==========================================================================================` ,
39
39
) ;
40
40
41
+ const paths = ( env . PATH || process . env . PATH ) ! . split ( delimiter ) ;
42
+
43
+ // Ensure the custom npm and yarn global bin is on the PATH
44
+ // https://docs.npmjs.com/cli/v8/configuring-npm/folders#executables
45
+ paths . unshift ( join ( getGlobalVariable ( 'yarn-global' ) , 'bin' ) ) ;
46
+ if ( process . platform . startsWith ( 'win' ) ) {
47
+ paths . unshift ( getGlobalVariable ( 'npm-global' ) ) ;
48
+ } else {
49
+ paths . unshift ( join ( getGlobalVariable ( 'npm-global' ) , 'bin' ) ) ;
50
+ }
51
+
41
52
args = args . filter ( ( x ) => x !== undefined ) ;
42
53
const flags = [
43
54
options . silent && 'silent' ,
@@ -52,7 +63,7 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
52
63
53
64
const spawnOptions : SpawnOptions = {
54
65
cwd,
55
- ... ( env ? { env } : { } ) ,
66
+ env : { ... env , PATH : paths . join ( delimiter ) } ,
56
67
} ;
57
68
58
69
if ( process . platform . startsWith ( 'win' ) ) {
@@ -147,15 +158,10 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
147
158
export function extractNpmEnv ( ) {
148
159
return Object . keys ( process . env )
149
160
. filter ( ( v ) => NPM_CONFIG_RE . test ( v ) )
150
- . reduce < NodeJS . ProcessEnv > (
151
- ( vars , n ) => {
152
- vars [ n ] = process . env [ n ] ;
153
- return vars ;
154
- } ,
155
- {
156
- PATH : process . env . PATH ,
157
- } ,
158
- ) ;
161
+ . reduce < NodeJS . ProcessEnv > ( ( vars , n ) => {
162
+ vars [ n ] = process . env [ n ] ;
163
+ return vars ;
164
+ } , { } ) ;
159
165
}
160
166
161
167
export function waitForAnyProcessOutputToMatch (
@@ -355,20 +361,12 @@ export async function launchTestProcess(entry: string, ...args: any[]) {
355
361
} ;
356
362
357
363
// Modify the PATH environment variable...
358
- let paths = process . env . PATH ! . split ( delimiter ) ;
364
+ let paths = ( env . PATH || process . env . PATH ) ! . split ( delimiter ) ;
359
365
360
366
// Only include paths within the sandboxed test environment or external
361
367
// non angular-cli paths such as /usr/bin for generic commands.
362
368
paths = paths . filter ( ( p ) => p . startsWith ( tempRoot ) || ! p . includes ( 'angular-cli' ) ) ;
363
369
364
- // Ensure the custom npm global bin is on the PATH
365
- // https://docs.npmjs.com/cli/v8/configuring-npm/folders#executables
366
- if ( process . platform . startsWith ( 'win' ) ) {
367
- paths . unshift ( env . NPM_CONFIG_PREFIX ! ) ;
368
- } else {
369
- paths . unshift ( join ( env . NPM_CONFIG_PREFIX ! , 'bin' ) ) ;
370
- }
371
-
372
370
env . PATH = paths . join ( delimiter ) ;
373
371
374
372
return _exec ( { env } , process . execPath , [ resolve ( __dirname , 'run_test_process' ) , entry , ...args ] ) ;
0 commit comments