Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): opening browser using CLI hangs the shell process forever #3480

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ the following file for use by subsequent Terraform commands:
try {
await open.default(this.terraformLoginURL, {
allowNonzeroExitCode: true,
wait: true,
wait: false, // Should remain false. Otherwise, it waits for the app (browser) to exit/quit, not just the window.
});
} catch (e) {
logger.debug(
Expand Down
23 changes: 23 additions & 0 deletions packages/cdktf-cli/src/test/cmds/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,27 @@ describe("init command", () => {
expect(result.stdout).not.toContain(`Detected Terraform Cloud token.`);
});
}, 30_000);

it("opens up the browser and waits for the token input", async () => {
await mkdtemp(async (cwd) => {
const input = "Y\n";
const result = await execa(
cdktfBin,
[
"init",
"--template=go",
"--from-terraform-project=false",
"--enable-crash-reporting=false",
],
{
stdio: "pipe",
cwd,
input,
}
);
expect(result.stderr).toEqual("");
expect(result.stdout).toContain(`opening webpage using your browser.`);
expect(result.stdout).toContain(`Token for app.terraform.io`);
});
}, 30_000);
});
Loading