@@ -12,6 +12,8 @@ export default async function () {
12
12
const npmRegistry : string = getGlobalVariable ( 'package-registry' ) ;
13
13
const npmrc = join ( tempRoot , '.npmrc' ) ;
14
14
const yarnrc = join ( tempRoot , '.yarnrc' ) ;
15
+ const npmCacheFolder = join ( tempRoot , 'npm-cache-folder' ) ;
16
+ const yarnCacheFolder = join ( tempRoot , 'yarn-cache-folder' ) ;
15
17
16
18
// Change the npm+yarn userconfig to the sandboxed npmrc to override the default ~
17
19
process . env . NPM_CONFIG_USERCONFIG = npmrc ;
@@ -24,6 +26,10 @@ export default async function () {
24
26
process . env . NPM_CONFIG_PREFIX = npmModulesPrefix ;
25
27
process . env . YARN_CONFIG_PREFIX = yarnModulesPrefix ;
26
28
29
+ // Package cache diretories
30
+ process . env . NPM_CONFIG_CACHE = npmCacheFolder ;
31
+ process . env . YARN_CACHE_FOLDER = yarnCacheFolder ;
32
+
27
33
// Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch).
28
34
// In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests.
29
35
// To support this case, legacy peer dependency mode is enabled for snapshot builds.
@@ -32,11 +38,19 @@ export default async function () {
32
38
}
33
39
34
40
// Configure the registry and prefix used within the test sandbox via rc files
35
- await writeFile ( npmrc , `registry=${ npmRegistry } \nprefix=${ npmModulesPrefix } ` ) ;
36
- await writeFile ( yarnrc , `registry ${ npmRegistry } \nprefix ${ yarnModulesPrefix } ` ) ;
41
+ await writeFile (
42
+ npmrc ,
43
+ `registry=${ npmRegistry } \nprefix=${ npmModulesPrefix } \ncache=${ npmCacheFolder } ` ,
44
+ ) ;
45
+ await writeFile (
46
+ yarnrc ,
47
+ `registry ${ npmRegistry } \nprefix ${ yarnModulesPrefix } \ncache-folder ${ yarnCacheFolder } ` ,
48
+ ) ;
37
49
38
50
await mkdir ( npmModulesPrefix ) ;
39
51
await mkdir ( yarnModulesPrefix ) ;
52
+ await mkdir ( npmCacheFolder ) ;
53
+ await mkdir ( yarnCacheFolder ) ;
40
54
41
55
setGlobalVariable ( 'npm-global' , npmModulesPrefix ) ;
42
56
setGlobalVariable ( 'yarn-global' , yarnModulesPrefix ) ;
0 commit comments