Skip to content

Commit 57e9f21

Browse files
authored
C3: Fix disappearing cursor after early exit (#4087)
* Fix c3 hiding cursor after cancelled input * changeset * fix lint issue
1 parent 35165a2 commit 57e9f21

File tree

4 files changed

+29
-99
lines changed

4 files changed

+29
-99
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
Fixes an issue where exiting early from c3 would cause the terminal cursor to be hidden

packages/create-cloudflare/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@types/yargs": "^17.0.22",
5959
"@typescript-eslint/eslint-plugin": "^5.55.0",
6060
"@typescript-eslint/parser": "^5.55.0",
61+
"ansi-escapes": "^6.2.0",
6162
"chalk": "^5.2.0",
6263
"command-exists": "^1.2.9",
6364
"cross-spawn": "^7.0.3",

packages/create-cloudflare/src/helpers/interactive.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TextPrompt, SelectPrompt, ConfirmPrompt } from "@clack/core";
2-
import { isCancel } from "@clack/prompts";
2+
import ansiEscapes from "ansi-escapes";
33
import logUpdate from "log-update";
44
import { shapes, cancel, space, status, newline } from "./cli";
55
import { blue, dim, gray, brandColor, bold } from "./colors";
@@ -97,11 +97,6 @@ export const inputPrompt = async (promptConfig: PromptConfig) => {
9797

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

100-
if (isCancel(input)) {
101-
cancel("Operation cancelled.");
102-
process.exit(0);
103-
}
104-
105100
return input;
106101
};
107102

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

126121
const handleCancel = () => {
122+
// Restore the cursor hidden by the select and confirm dialogs
123+
process.stdout.write(ansiEscapes.cursorShow);
127124
cancel("Operation cancelled.");
128125
process.exit(0);
129126
};

0 commit comments

Comments
 (0)