refactor: simplify spinner handling and remove duplicate messages

- Move spinner.stop() before conditional to eliminate code duplication
- Remove duplicate success message (caller already shows detailed message)
- Simplify error handling (caller handles error messages)

Addresses Copilot feedback on PR #921
This commit is contained in:
Wojciech Tyziniec 2025-11-15 17:22:55 +01:00
parent d05f6ee420
commit 59ed774154
No known key found for this signature in database
GPG Key ID: F4E491E5D0CE9709
1 changed files with 9 additions and 14 deletions

View File

@ -1762,13 +1762,11 @@ class Installer {
const existingBmadFolderName = path.basename(bmadDir); const existingBmadFolderName = path.basename(bmadDir);
const newBmadFolderName = this.configCollector.collectedConfig.core?.bmad_folder || existingBmadFolderName; const newBmadFolderName = this.configCollector.collectedConfig.core?.bmad_folder || existingBmadFolderName;
if (existingBmadFolderName === newBmadFolderName) { // Stop spinner before calling install() since install() manages its own spinner
// Normal quick update - stop spinner before calling install() spinner.stop();
// install() will manage its own spinner
spinner.stop(); // Notify user if folder name will change
} else { if (existingBmadFolderName !== newBmadFolderName) {
// Folder name has changed - notify user that install() will handle migration
spinner.stop();
console.log(chalk.yellow(`\n⚠️ Folder name will change: ${existingBmadFolderName}${newBmadFolderName}`)); console.log(chalk.yellow(`\n⚠️ Folder name will change: ${existingBmadFolderName}${newBmadFolderName}`));
console.log(chalk.yellow('The installer will handle the folder migration.\n')); console.log(chalk.yellow('The installer will handle the folder migration.\n'));
} }
@ -1790,9 +1788,8 @@ class Installer {
// Call the standard install method (it will manage its own spinner) // Call the standard install method (it will manage its own spinner)
const result = await this.install(installConfig); const result = await this.install(installConfig);
// install() handles its own spinner, so no need to check if our spinner is spinning // Note: Completion message is shown by the caller in commands/install.js
// Just show completion message // to avoid duplication and provide more detailed success information
console.log(chalk.green('✓ Quick update complete!'));
return { return {
success: true, success: true,
@ -1803,11 +1800,9 @@ class Installer {
ides: configuredIdes, ides: configuredIdes,
}; };
} catch (error) { } catch (error) {
// Spinner is already stopped, just show error // Ensure spinner is stopped, then let caller handle error message
if (spinner.isSpinning) { if (spinner.isSpinning) {
spinner.fail('Quick update failed'); spinner.stop();
} else {
console.error(chalk.red('✗ Quick update failed'));
} }
throw error; throw error;
} }