fix: address PR #373 review feedback

- postuninstall.js: add file logging for debugging on error
- profile-hook-injector.ts: use 'wx' flag for atomic marker creation
- profile-hook-injector.ts: include parse error message in debug log
- install-command.ts: use actual counts for consistent semantics
- Windows tests: align Section 7 with per-profile hook architecture
This commit is contained in:
kaitranntt
2026-01-25 22:02:25 -05:00
parent e0891fe915
commit e98a92fded
4 changed files with 43 additions and 51 deletions
+6 -4
View File
@@ -63,8 +63,8 @@ function migrateGlobalHook(): void {
if (!fs.existsSync(ccsDir)) {
fs.mkdirSync(ccsDir, { recursive: true, mode: 0o700 });
}
// Create marker file
fs.writeFileSync(markerPath, new Date().toISOString(), 'utf8');
// Create marker file atomically (wx = fail if exists, prevents race condition)
fs.writeFileSync(markerPath, new Date().toISOString(), { encoding: 'utf8', flag: 'wx' });
} catch (error) {
if (process.env.CCS_DEBUG) {
console.error(warn(`Migration failed: ${(error as Error).message}`));
@@ -114,9 +114,11 @@ export function ensureProfileHooks(profileName: string): boolean {
try {
const content = fs.readFileSync(settingsPath, 'utf8');
settings = JSON.parse(content);
} catch {
} catch (parseError) {
if (process.env.CCS_DEBUG) {
console.error(warn(`Malformed ${profileName}.settings.json - creating fresh hooks`));
console.error(
warn(`Malformed ${profileName}.settings.json: ${(parseError as Error).message}`)
);
}
// Continue with empty settings, will add hooks
}