fix(install): escape/Ctrl+C cancels instead of installing globally

Previously, closing the readline (via Escape, Ctrl+C, or stdin closure)
would default to global install. Now it cancels the installation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson
2026-01-21 12:42:02 -06:00
parent a1d60b7160
commit 67201cb039

View File

@@ -533,15 +533,12 @@ function promptLocation() {
// Track whether we've processed the answer to prevent double-execution
let answered = false;
// Handle readline close event to detect premature stdin closure
// Handle readline close event (Ctrl+C, Escape, etc.) - cancel installation
rl.on('close', () => {
if (!answered) {
answered = true;
console.log(`\n ${yellow}Input stream closed, defaulting to global install${reset}\n`);
const { settingsPath, settings, statuslineCommand } = install(true);
handleStatusline(settings, false, (shouldInstallStatusline) => {
finishInstall(settingsPath, settings, statuslineCommand, shouldInstallStatusline);
});
console.log(`\n ${yellow}Installation cancelled${reset}\n`);
process.exit(0);
}
});