create-t3-app icon indicating copy to clipboard operation
create-t3-app copied to clipboard

bug: CTRL+C when scaffolding into an existing directory doesn't exit

Open c-ehrlich opened this issue 2 years ago • 3 comments

Provide environment information

7.22.0

Describe the bug

I pressed CTRL+C in response to each of the prompts in the screenshot below. iTerm2 on MacOS.

CleanShot 2023-10-16 at 10 34 26@2x

CTRL+C in "Warning: <PROJECTNAME> already exists and isn't empty. How would you like to proceed?" => picks override CTRL+C in "Are you sure you want to overwrite conflicting files?" => picks yes CTRL+C in "Warning: Git is already initialized in "<PROJECTNAME>". Initializing a new git repository would delete the previous history. Would you like to continue anyways?" => picks yes

expected behaviour: CTRL+C at any of these points exits the CLI without scaffolding anything

Reproduction repo

To reproduce

  • initialize an app into some directory
  • initialize into the same directory again
  • press CTRL+C when asked about existing files etc

Additional information

No response

c-ehrlich avatar Oct 16 '23 08:10 c-ehrlich

I can confirm this bug as of today (2023-10-19) in next branch.

The issue is because clack prompt can return either a string or a symbol to inform about the user cancelling the prompt and the symbol is not being considered at all.

clack exports an useful function called isCancel which is exactly what we need here.

I can submit a PR but I have doubts with the last step.

CTRL+C in "Warning: Git is already initialized in "". Initializing a new git repository would delete the previous history. Would you like to continue anyways?" => picks yes

Doing a cancel here would only stop git being initialized, instead of stopping the scaffold as @c-ehrlich mentioned which I think is fine but would love to read other opinions.

hodeinavarro avatar Oct 19 '23 21:10 hodeinavarro

IMO if the user exits the CLI before making all decisions, nothing should happen. @juliusmarminge thoughts?

c-ehrlich avatar Oct 20 '23 05:10 c-ehrlich

ctrl+c should cancel the CLI entirely i feel like?

whether it exits with 0 or non 0 exit code idk

juliusmarminge avatar Oct 20 '23 07:10 juliusmarminge