fix(hooks): avoid escaped quotes in plugin bootstrap

Generate the inline hook root resolver with single-quoted JavaScript literals so Windows Git Bash does not choke on nested escaped double quotes before Node starts. Refresh hooks.json and add regression coverage for parsed hook commands and installed hook manifests.
This commit is contained in:
Affaan Mustafa
2026-05-19 05:05:26 -04:00
committed by Affaan Mustafa
parent f93e8f6869
commit 6cb194a3c6
6 changed files with 74 additions and 24 deletions

View File

@@ -2513,6 +2513,29 @@ async function runTests() {
passed++;
else failed++;
if (
test('inline hook bootstraps avoid escaped double quotes for Git Bash', () => {
const hooksPath = path.join(__dirname, '..', '..', 'hooks', 'hooks.json');
const hooks = JSON.parse(fs.readFileSync(hooksPath, 'utf8'));
for (const [eventName, hookArray] of Object.entries(hooks.hooks)) {
for (const entry of hookArray) {
for (const hook of entry.hooks) {
const commandText = Array.isArray(hook.command) ? hook.command.join(' ') : hook.command;
if (typeof commandText === 'string' && commandText.startsWith('node -e ')) {
assert.ok(
!commandText.includes('\\"'),
`${eventName}/${entry.id || entry.matcher || 'hook'} should not ship escaped double quotes in node -e payload`,
);
}
}
}
}
})
)
passed++;
else failed++;
if (
test('all hook commands use node or approved shell wrappers', () => {
const hooksPath = path.join(__dirname, '..', '..', 'hooks', 'hooks.json');