Skip to content

Commit 2a938ee

Browse files
committed
test: wip: add yarnrc
1 parent ca0a31a commit 2a938ee

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

tests/legacy-cli/e2e/setup/002-npm-sandbox.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { mkdir, writeFile } from 'fs/promises';
22
import { join } from 'path';
33
import { getGlobalVariable, setGlobalVariable } from '../utils/env';
4+
import { globalYarn } from '../utils/process';
45

56
/**
67
* Configure npm to use a unique sandboxed environment.
@@ -11,6 +12,7 @@ export default async function () {
1112
const yarnModulesPrefix = join(tempRoot, 'yarn-global');
1213
const npmRegistry: string = getGlobalVariable('package-registry');
1314
const npmrc = join(tempRoot, '.npmrc');
15+
const yarnrc = join(tempRoot, '.yarnrc');
1416

1517
// Configure npm to use the sandboxed npm globals and rc file
1618
// From this point onward all npm transactions use the "global" npm cache
@@ -28,11 +30,16 @@ export default async function () {
2830

2931
// Configure the registry and create the prefix directories
3032
await writeFile(npmrc, `registry=${npmRegistry}\nprefix=${npmModulesPrefix}`);
33+
await writeFile(yarnrc, `registry ${npmRegistry}\nprefix ${yarnModulesPrefix}`);
3134
await mkdir(npmModulesPrefix);
3235
await mkdir(yarnModulesPrefix);
3336

3437
setGlobalVariable('npm-global', npmModulesPrefix);
3538
setGlobalVariable('yarn-global', yarnModulesPrefix);
3639

40+
console.log('YARN INFO: ');
41+
await globalYarn(['config', 'set', 'prefix', '/tmp/foobar']);
42+
await globalYarn(['global', 'bin']);
43+
3744
console.log(` Using "${npmModulesPrefix}" as e2e test global npm cache.`);
3845
}

tests/legacy-cli/e2e/utils/process.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export function globalYarn(args: string[], env?: NodeJS.ProcessEnv) {
330330
try {
331331
process.env.NPM_CONFIG_PREFIX = getGlobalVariable('yarn-global');
332332

333-
return _exec({ silent: true, env }, 'node', [YARN, ...args]);
333+
return _exec({ silent: false, env }, 'node', [YARN, ...args]);
334334
} finally {
335335
process.env.NPM_CONFIG_PREFIX = npmPrefix;
336336
}

0 commit comments

Comments
 (0)