Preserve detector extensions

AI assistance: Codex addressed review feedback and validated this follow-up under maintainer authorization.
This commit is contained in:
Paul Bakaus
2026-08-03 10:23:13 -07:00
parent ae118ebf57
commit 57ce11288f
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -223,7 +223,11 @@ function writeHookConfig(cwd, hookConfig, opts = {}) {
// (consent, quiet, auditLog) survive an Impeccable hooks edit.
const next = { ...existing, hook: { ...existingHook, ...hookConfig } };
if (Object.keys(legacyDetector).length > 0) {
next.detector = mergeDetectorConfig(detectorSection(existing), mergeDetectorConfig(legacyDetector));
const existingDetector = detectorSection(existing) || {};
next.detector = {
...existingDetector,
...mergeDetectorConfig(existingDetector, mergeDetectorConfig(legacyDetector)),
};
}
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, JSON.stringify(next, null, 2) + '\n');
+5 -1
View File
@@ -1026,7 +1026,10 @@ describe('hook-admin.mjs', () => {
fs.mkdirSync(path.dirname(getConfigPath(cwd)), { recursive: true });
fs.writeFileSync(getConfigPath(cwd), JSON.stringify({
hook: { advisoryRules: 'include' },
detector: { advisoryRules: 'exclude' },
detector: {
advisoryRules: 'exclude',
extensions: [{ ext: '.blade.php', engine: 'html' }],
},
}));
runAdmin(['on']);
@@ -1034,6 +1037,7 @@ describe('hook-admin.mjs', () => {
const config = JSON.parse(fs.readFileSync(getConfigPath(cwd), 'utf-8'));
assert.equal(config.hook.advisoryRules, undefined);
assert.equal(config.detector.advisoryRules, 'exclude');
assert.deepEqual(config.detector.extensions, [{ ext: '.blade.php', engine: 'html' }]);
});
it('ignore-file refuses unsupported reasons and unknown flags', () => {