Skip to content

Commit

Permalink
[cli] Add test for CLI extensions passing through exit code (#11600)
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed May 15, 2024
1 parent 1eb76a3 commit 9ee7d31
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .changeset/gorgeous-cycles-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"cli-extension-fail": "file:../cli-extension-fail"
}
}
2 changes: 2 additions & 0 deletions packages/cli/test/fixtures/e2e/cli-extension-fail/bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
process.exit(6);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "cli-extension-fail",
"bin": {
"vercel-fail": "bin.js"
}
}
13 changes: 13 additions & 0 deletions packages/cli/test/integration-3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,19 @@ test('should invoke CLI extension', async () => {
expect(output.stdout, formatted).toContain(`Username: ${contextName}`);
});

test('should pass through exit code for CLI extension', async () => {
const fixture = path.join(__dirname, 'fixtures/e2e/cli-extension-exit-code');

// Ensure the `.bin` is populated in the fixture
await runNpmInstall(fixture);

const output = await execCli(binaryPath, ['fail'], {
cwd: fixture,
reject: false,
});
expect(output.exitCode).toEqual(6);
});

// NOTE: Order matters here. This must be the last test in the file.
test('default command should prompt login with empty auth.json', async () => {
await clearAuthConfig();
Expand Down

0 comments on commit 9ee7d31

Please sign in to comment.