Skip to content

Commit c3b73f7

Browse files
committed
feat: when strict checking is off, treat like transparent
1 parent 0b7abb9 commit c3b73f7

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

sources/specUtils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export async function findProjectSpec(initialCwd: string, locator: Locator, {tra
4444
// A locator is a valid descriptor (but not the other way around)
4545
const fallbackLocator = {name: locator.name, range: locator.reference};
4646

47-
if (process.env.COREPACK_ENABLE_STRICT === `0`) return fallbackLocator;
47+
if (process.env.COREPACK_ENABLE_STRICT === `0`)
48+
transparent = true;
4849

4950
while (true) {
5051
const result = await loadSpec(initialCwd);

tests/main.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,31 @@ it(`should refuse to run a different package manager within a configured project
281281
});
282282
});
283283

284+
285+
it(`should use project-specified version when strict checking is turned off`, async () => {
286+
await xfs.mktempPromise(async cwd => {
287+
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
288+
packageManager: `[email protected]`,
289+
});
290+
291+
process.env.COREPACK_ENABLE_STRICT = `0`;
292+
293+
try {
294+
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
295+
stdout: `2.2.2\n`,
296+
stderr: ``,
297+
exitCode: 0,
298+
});
299+
await expect(runCli(cwd, [`pnpm`, `--version`])).resolves.toMatchObject({
300+
stdout: `${config.definitions.pnpm.default.split(`+`, 1)[0]}\n`,
301+
exitCode: 0,
302+
});
303+
} finally {
304+
delete process.env.COREPACK_ENABLE_STRICT;
305+
}
306+
});
307+
});
308+
284309
it(`should allow to call "prepare" with --all to prepare all package managers`, async () => {
285310
await xfs.mktempPromise(async cwd => {
286311
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {

0 commit comments

Comments
 (0)