@@ -8,28 +8,39 @@ import { getGlobalVariable, setGlobalVariable } from '../utils/env';
8
8
export default async function ( ) {
9
9
const tempRoot : string = getGlobalVariable ( 'tmp-root' ) ;
10
10
const npmModulesPrefix = join ( tempRoot , 'npm-global' ) ;
11
+ const yarnModulesPrefix = join ( tempRoot , 'yarn-global' ) ;
11
12
const npmRegistry : string = getGlobalVariable ( 'package-registry' ) ;
12
13
const npmrc = join ( tempRoot , '.npmrc' ) ;
14
+ const yarnrc = join ( tempRoot , '.yarnrc' ) ;
13
15
14
- // Configure npm to use the sandboxed npm globals and rc file
15
- // From this point onward all npm transactions use the "global" npm cache
16
- // isolated within this e2e test invocation.
16
+ // Change the npm+yarn userconfig to the sandboxed npmrc to override the default ~
17
17
process . env . NPM_CONFIG_USERCONFIG = npmrc ;
18
- process . env . NPM_CONFIG_PREFIX = npmModulesPrefix ;
18
+
19
+ // The npm+yarn registry URL
19
20
process . env . NPM_CONFIG_REGISTRY = npmRegistry ;
20
21
22
+ // Configure npm+yarn to use a sandboxed bin directory
23
+ // From this point onward all yarn/npm bin files/symlinks are put into the prefix directories
24
+ process . env . NPM_CONFIG_PREFIX = npmModulesPrefix ;
25
+ process . env . YARN_CONFIG_PREFIX = yarnModulesPrefix ;
26
+
21
27
// Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch).
22
28
// In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests.
23
29
// To support this case, legacy peer dependency mode is enabled for snapshot builds.
24
30
if ( getGlobalVariable ( 'argv' ) [ 'ng-snapshots' ] ) {
25
31
process . env [ 'NPM_CONFIG_legacy_peer_deps' ] = 'true' ;
26
32
}
27
33
28
- // Configure the registry and prefix used within the test sandbox
34
+ // Configure the registry and prefix used within the test sandbox via rc files
29
35
await writeFile ( npmrc , `registry=${ npmRegistry } \nprefix=${ npmModulesPrefix } ` ) ;
36
+ await writeFile ( yarnrc , `registry ${ npmRegistry } \nprefix ${ yarnModulesPrefix } ` ) ;
37
+
30
38
await mkdir ( npmModulesPrefix ) ;
39
+ await mkdir ( yarnModulesPrefix ) ;
31
40
32
41
setGlobalVariable ( 'npm-global' , npmModulesPrefix ) ;
42
+ setGlobalVariable ( 'yarn-global' , yarnModulesPrefix ) ;
33
43
34
- console . log ( ` Using "${ npmModulesPrefix } " as e2e test global npm cache.` ) ;
44
+ console . log ( ` Using "${ npmModulesPrefix } " as e2e test global npm bin dir.` ) ;
45
+ console . log ( ` Using "${ yarnModulesPrefix } " as e2e test global yarn bin dir.` ) ;
35
46
}
0 commit comments