Skip to content

Commit

Permalink
C3: Fix disappearing cursor after early exit (#4087)
Browse files Browse the repository at this point in the history
* Fix c3 hiding cursor after cancelled input

* changeset

* fix lint issue
  • Loading branch information
jculvey authored Oct 3, 2023
1 parent 35165a2 commit 57e9f21
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-sloths-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": patch
---

Fixes an issue where exiting early from c3 would cause the terminal cursor to be hidden
1 change: 1 addition & 0 deletions packages/create-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@types/yargs": "^17.0.22",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"ansi-escapes": "^6.2.0",
"chalk": "^5.2.0",
"command-exists": "^1.2.9",
"cross-spawn": "^7.0.3",
Expand Down
9 changes: 3 additions & 6 deletions packages/create-cloudflare/src/helpers/interactive.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TextPrompt, SelectPrompt, ConfirmPrompt } from "@clack/core";
import { isCancel } from "@clack/prompts";
import ansiEscapes from "ansi-escapes";
import logUpdate from "log-update";
import { shapes, cancel, space, status, newline } from "./cli";
import { blue, dim, gray, brandColor, bold } from "./colors";
Expand Down Expand Up @@ -97,11 +97,6 @@ export const inputPrompt = async (promptConfig: PromptConfig) => {

const input = (await prompt.prompt()) as string;

if (isCancel(input)) {
cancel("Operation cancelled.");
process.exit(0);
}

return input;
};

Expand All @@ -124,6 +119,8 @@ const renderSubmit = (config: PromptConfig, value: string) => {
};

const handleCancel = () => {
// Restore the cursor hidden by the select and confirm dialogs
process.stdout.write(ansiEscapes.cursorShow);
cancel("Operation cancelled.");
process.exit(0);
};
Expand Down
Loading

0 comments on commit 57e9f21

Please sign in to comment.