mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 06:06:37 +03:00
Preserve detector extension mappings
Keep unmanaged detector fields when ignore-file updates the canonical detector configuration. Add a regression covering existing extension mappings.\n\nAI assistance: Codex implemented and validated this change under maintainer authorization.
This commit is contained in:
@@ -240,10 +240,14 @@ function writeDetectorConfig(cwd, detectorConfig, opts = {}) {
|
||||
const existingRaw = readRawConfigFile(filePath).raw;
|
||||
const existing = existingRaw && typeof existingRaw === 'object' && !Array.isArray(existingRaw) ? existingRaw : {};
|
||||
const nextHook = stripDetectorKeys(hookSection(existing));
|
||||
const existingDetector = mergeDetectorConfig(detectorSection(existing));
|
||||
const existingDetectorSection = detectorSection(existing) || {};
|
||||
const existingDetector = mergeDetectorConfig(existingDetectorSection);
|
||||
const next = {
|
||||
...existing,
|
||||
detector: mergeDetectorConfig(detectorConfig, existingDetector),
|
||||
detector: {
|
||||
...existingDetectorSection,
|
||||
...mergeDetectorConfig(detectorConfig, existingDetector),
|
||||
},
|
||||
};
|
||||
if (Object.keys(nextHook).length > 0) next.hook = nextHook;
|
||||
else delete next.hook;
|
||||
|
||||
@@ -1058,9 +1058,15 @@ describe('hook-admin.mjs', () => {
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.writeFileSync(file, '<div style="border-left: 4px solid #7c3aed; border-radius: 16px; padding: 16px;">Card</div>');
|
||||
|
||||
fs.mkdirSync(path.dirname(getConfigPath(cwd)), { recursive: true });
|
||||
fs.writeFileSync(getConfigPath(cwd), JSON.stringify({
|
||||
detector: { extensions: [{ ext: '.blade.php', engine: 'html' }] },
|
||||
}));
|
||||
|
||||
runAdmin(['ignore-file', 'src/ConfirmedCard.html']);
|
||||
|
||||
const shared = JSON.parse(fs.readFileSync(getConfigPath(cwd), 'utf-8')).detector;
|
||||
assert.deepEqual(shared.extensions, [{ ext: '.blade.php', engine: 'html' }]);
|
||||
assert.deepEqual(shared.ignoreFiles, ['src/ConfirmedCard.html']);
|
||||
|
||||
const r = await runHook({
|
||||
|
||||
Reference in New Issue
Block a user