-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
COREPACK_ENABLE_STRICT
env variable (#167)
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,6 +219,34 @@ it(`should allow to call "prepare" without arguments within a configured project | |
}); | ||
}); | ||
|
||
it(`should refuse to run a different package manager within a configured project`, async () => { | ||
await xfs.mktempPromise(async cwd => { | ||
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { | ||
packageManager: `[email protected]`, | ||
}); | ||
|
||
process.env.FORCE_COLOR = `0`; | ||
|
||
await expect(runCli(cwd, [`pnpm`, `--version`])).resolves.toMatchObject({ | ||
stdout: `Usage Error: This project is configured to use yarn\n\n$ pnpm ...\n`, | ||
exitCode: 1, | ||
}); | ||
|
||
// Disable strict checking to workaround the UsageError. | ||
process.env.COREPACK_ENABLE_STRICT = `0`; | ||
|
||
try { | ||
await expect(runCli(cwd, [`pnpm`, `--version`])).resolves.toMatchObject({ | ||
stdout: `${config.definitions.pnpm.default.split(`+`, 1)[0]}\n`, | ||
exitCode: 0, | ||
}); | ||
} finally { | ||
delete process.env.COREPACK_ENABLE_STRICT; | ||
delete process.env.FORCE_COLOR; | ||
} | ||
}); | ||
}); | ||
|
||
it(`should allow to call "prepare" with --all to prepare all package managers`, async () => { | ||
await xfs.mktempPromise(async cwd => { | ||
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { | ||
|