Skip to content

Commit

Permalink
test: escape hatch for test CI's implied no-check-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jj811208 committed Sep 18, 2022
1 parent 1e55898 commit 1008f91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,14 @@ export const generatePkgDriver = ({

// We want users to be aware of the security implications of zero-install, but we don't want it to affect yarn own testing.
if (args[0] === `install`) {
// escape hatch for test use only
const escapeHatchIndex = args.indexOf(`--check-cache-test`);
const hasEscapeHatch = args.indexOf(`--check-cache-test`) !== -1;
if (hasEscapeHatch)
args.splice(escapeHatchIndex, 1);

const hasCheckCacheOption = args.includes(`--check-cache`) || args.includes(`--no-check-cache`);
if (!hasCheckCacheOption) {
if (!hasCheckCacheOption && !hasEscapeHatch) {
args.push(`--no-check-cache`);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ describe(`Commands`, () => {
// mock zero-install environment
await xfs.mkdirPromise(ppath.join(path, `.yarn`));
await xfs.mkdirPromise(ppath.join(path, `.yarn/cache`));
await expect(run(`install`, {env: {CI: true}})).rejects.toMatchObject({
await expect(run(`install`, `--check-cache-test`, {env: {CI: true}})).rejects.toMatchObject({
code: 1,
stdout: expect.stringMatching(`you need to explicitly define --check-cache or --no-check-cache option`),
});
Expand Down

0 comments on commit 1008f91

Please sign in to comment.