fix: address PR review — shebang, double-escaping, data loss, uninstall scope
- Add shebang banner to NPX CLI esbuild config so npx claude-mem works - Remove manual backslash pre-escaping in WindsurfHooksInstaller (JSON.stringify handles it) - Scope cache deletion to claude-mem only, not entire vendor namespace - Use getWorkerPort() in OpenCodeInstaller instead of hard-coded 37777 - Throw on corrupt JSON in readJsonSafe/readGeminiSettings/Windsurf to prevent data loss - Fix Cursor install stub to warn instead of silently succeeding - Fix Gemini uninstall to remove individual hooks within groups, not whole groups - Update tests for new corrupt-file-throws behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,23 +46,22 @@ describe('JSON Utils', () => {
|
||||
expect(result).toEqual(data);
|
||||
});
|
||||
|
||||
it('returns default value for corrupt JSON file', () => {
|
||||
it('throws on corrupt JSON file to prevent data loss', () => {
|
||||
const filePath = join(tempDir, 'corrupt.json');
|
||||
writeFileSync(filePath, 'this is not valid json {{{');
|
||||
|
||||
const defaultValue = { recovered: true };
|
||||
const result = readJsonSafe(filePath, defaultValue);
|
||||
|
||||
expect(result).toEqual(defaultValue);
|
||||
expect(() => readJsonSafe(filePath, { recovered: true })).toThrow(
|
||||
/Corrupt JSON file, refusing to overwrite/
|
||||
);
|
||||
});
|
||||
|
||||
it('returns default value for empty file', () => {
|
||||
it('throws on empty file to prevent data loss', () => {
|
||||
const filePath = join(tempDir, 'empty.json');
|
||||
writeFileSync(filePath, '');
|
||||
|
||||
const result = readJsonSafe(filePath, []);
|
||||
|
||||
expect(result).toEqual([]);
|
||||
expect(() => readJsonSafe(filePath, [])).toThrow(
|
||||
/Corrupt JSON file, refusing to overwrite/
|
||||
);
|
||||
});
|
||||
|
||||
it('works with array default values', () => {
|
||||
|
||||
Reference in New Issue
Block a user