Skip to content

Commit

Permalink
chore: add extra try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Jan 18, 2024
1 parent 7ee3f4c commit 3e449a1
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/cdktf-cli/src/bin/cmds/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import path from "path";
import os from "os";
import { readPackageJson, projectRootPath } from "./helper/utilities";
import { readSchema } from "@cdktf/provider-schema";
import { editor, input } from "@inquirer/prompts";
import { editor } from "@inquirer/prompts";

const chalkColour = new chalk.Instance();
const config = readConfigSync();
Expand Down Expand Up @@ -115,12 +115,18 @@ export async function convert({
input = await readStreamAsString(process.stdin);
} catch (e) {
logger.debug(`No TTY stream passed to convert, using interactive input`);
input = await editor({
message:
"Enter your Terrafrom code to convert to cdktf (or run the command again and pass it as stdin):",
postfix: ".tf",
waitForUseInput: true,
});
try {
input = await editor({
message:
"Enter your Terrafrom code to convert to cdktf (or run the command again and pass it as stdin):",
postfix: ".tf",
waitForUseInput: true,
});
} catch (err) {
throw Errors.Usage(
"No Terraform code to convert was provided. Please provide Terraform code to convert as stdin or run the command again and let the CLI open the editor."
);
}
}

const needsProject = language !== "typescript";
Expand Down Expand Up @@ -423,7 +429,7 @@ export async function login(argv: { tfeHostname: string }) {
if (token) {
await terraformLogin.saveTerraformCredentials(sanitizedToken);
} else {
token = await terraformLogin.askToLogin();
token = await terraformLogin.askToLogin(false);
if (token === "") {
throw Errors.Usage(`No Terraform Cloud token was provided.`);
}
Expand Down

0 comments on commit 3e449a1

Please sign in to comment.