create-t3-app
create-t3-app copied to clipboard
bug: CTRL+C when scaffolding into an existing directory doesn't exit
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.
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
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.
IMO if the user exits the CLI before making all decisions, nothing should happen. @juliusmarminge thoughts?
ctrl+c should cancel the CLI entirely i feel like?
whether it exits with 0 or non 0 exit code idk