Skip to content

Commit 6d1f26f

Browse files
WIP add yarnBerry to test suite
1 parent 282f906 commit 6d1f26f

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

src/test/cli-options.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as assert from 'uvu/assert';
99
import {suite} from 'uvu';
1010
import {rigTest} from './util/rig-test.js';
1111
import {WireitTestRig} from './util/test-rig.js';
12-
import {Options} from '../cli-options.js';
12+
import {Agent, Options} from '../cli-options.js';
1313
import {Result} from '../error.js';
1414

1515
const test = suite<object>();
@@ -67,8 +67,8 @@ async function assertOptions(
6767
});
6868
}
6969

70-
for (const command of ['npm', 'yarn', 'pnpm'] as const) {
71-
const agent = command === 'yarn' ? 'yarnClassic' : command;
70+
for (const command of ['npm', 'yarn', 'pnpm', 'yarnBerry'] as const) {
71+
const agent: Agent = command === 'yarn' ? 'yarnClassic' : command;
7272
// eslint-disable-next-line @typescript-eslint/unbound-method
7373
const skipIfYarn = command === 'yarn' ? test.skip : test;
7474
// eslint-disable-next-line @typescript-eslint/unbound-method

src/test/util/test-rig.ts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,33 @@ export class WireitTestRig
6464
*/
6565
override async setup() {
6666
await super.setup();
67-
const absWireitBinaryPath = pathlib.resolve(repoRoot, 'bin', 'wireit.js');
68-
const absWireitTempInstallPath = pathlib.resolve(
69-
this.temp,
70-
'node_modules',
71-
'.bin',
72-
'wireit',
67+
68+
Promise.all(
69+
[
70+
['wireit', ['bin', 'wireit.js']] as const,
71+
['yarnBerry', ['.yarn', 'releases', 'yarn-4.0.1.cjs']] as const,
72+
].map(
73+
async ([ name, pathParts ]) => {
74+
const binaryPath = pathlib.resolve(repoRoot, ...pathParts);
75+
const tempInstallPath = pathlib.resolve(
76+
this.temp,
77+
'node_modules',
78+
'.bin',
79+
name,
80+
);
81+
82+
if (IS_WINDOWS) {
83+
// Npm install works differently on Windows, since it won't recognize a
84+
// shebang like "#!/usr/bin/env node". Npm instead uses the cmd-shim
85+
// package to generate Windows shell wrappers for each binary, so we do
86+
// that here too.
87+
await cmdShim(binaryPath, tempInstallPath);
88+
} else {
89+
await this.symlink(binaryPath, tempInstallPath, 'file');
90+
}
91+
}
92+
)
7393
);
74-
if (IS_WINDOWS) {
75-
// Npm install works differently on Windows, since it won't recognize a
76-
// shebang like "#!/usr/bin/env node". Npm instead uses the cmd-shim
77-
// package to generate Windows shell wrappers for each binary, so we do
78-
// that here too.
79-
await cmdShim(absWireitBinaryPath, absWireitTempInstallPath);
80-
} else {
81-
await this.symlink(absWireitBinaryPath, absWireitTempInstallPath, 'file');
82-
}
8394
}
8495

8596
/**

0 commit comments

Comments
 (0)