Skip to content

fix: non-ASCII cleanup and backup robustness#9

Merged
doanbactam merged 1 commit intomasterfrom
fix/hook-backup-before-overwrite
Apr 3, 2026
Merged

fix: non-ASCII cleanup and backup robustness#9
doanbactam merged 1 commit intomasterfrom
fix/hook-backup-before-overwrite

Conversation

@doanbactam
Copy link
Copy Markdown
Owner

@doanbactam doanbactam commented Apr 3, 2026

Summary

  • Remove all non-ASCII characters (emoji, em dash, box drawing, checkmarks) from source code files for cross-terminal/encoding compatibility
  • Deduplicate fileExists() in cli.ts by reusing the shared pathExists() utility from paths.ts
  • Fix TOCTOU anti-pattern in backup/restore logic — operate directly with try/catch instead of pre-checking file existence
  • Extract HOOK_BACKUP_EXT constant to replace .bak magic string scattered across install/uninstall
  • Replace inline fs.access().then().catch() patterns in uninstall.ts with the existing pathExists() utility

Test plan

  • bun test — 38/38 tests pass
  • npm run build — dist rebuilt successfully
  • grep -P '[^\x00-\x7F]' — no remaining non-ASCII in source files
  • Manual: verify npx nococli install + uninstall on a repo with an existing non-nococli hook

- Remove emoji and Unicode symbols (em dash, box drawing, checkmarks)
  from source code files for cross-terminal compatibility
- Deduplicate fileExists() in cli.ts by reusing pathExists() utility
- Fix TOCTOU anti-pattern in backup/restore logic (try/catch instead
  of pre-check existence)
- Extract HOOK_BACKUP_EXT constant to eliminate magic string
- Replace inline fs.access checks in uninstall.ts with pathExists()
@doanbactam doanbactam force-pushed the fix/hook-backup-before-overwrite branch from 540d786 to 207ba59 Compare April 3, 2026 10:21
@doanbactam doanbactam merged commit 848a9f6 into master Apr 3, 2026
2 checks passed
@doanbactam doanbactam deleted the fix/hook-backup-before-overwrite branch April 3, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants