[cli] Add test for CLI extensions passing through exit code (#11600)

/cc @codybrouwers
This commit is contained in:
Nathan Rajlich
2024-05-15 13:02:40 -07:00
committed by GitHub
parent 1eb76a3ae7
commit 9ee7d31957
6 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
---
---

View File

@@ -0,0 +1,32 @@
{
"name": "cli-extension-exit-code",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"cli-extension-fail": "file:../cli-extension-fail"
}
},
"../cli-extension-fail": {
"bin": {
"vercel-fail": "bin.js"
}
},
"../cli-extension-whoami": {
"extraneous": true,
"bin": {
"vercel-mywhoami": "bin.js"
}
},
"node_modules/cli-extension-fail": {
"resolved": "../cli-extension-fail",
"link": true
}
},
"dependencies": {
"cli-extension-fail": {
"version": "file:../cli-extension-fail"
}
}
}

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"cli-extension-fail": "file:../cli-extension-fail"
}
}

View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
process.exit(6);

View File

@@ -0,0 +1,6 @@
{
"name": "cli-extension-fail",
"bin": {
"vercel-fail": "bin.js"
}
}

View File

@@ -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();