Fix(hooks): normalize Windows managed hook script paths (#3396)

* fix: normalize windows managed hook script paths

* chore: add changeset for codex hook paths

* docs: hyphenate windows managed hooks changeset
This commit is contained in:
Tom Boucher
2026-05-11 15:27:44 -04:00
committed by GitHub
parent e79c472d7b
commit 1f99085559
3 changed files with 33 additions and 1 deletions

View File

@@ -607,6 +607,12 @@ function formatHookCommandForShell(command, opts) {
return platform === 'win32' ? `& ${command}` : command;
}
function formatManagedHookScriptToken(scriptPath, opts) {
const platform = (opts && opts.platform) || process.platform;
if (platform !== 'win32') return null;
return JSON.stringify(scriptPath.replace(/\\/g, '/'));
}
function rewriteLegacyManagedNodeHookCommands(settings, absoluteRunner, opts) {
if (!settings || !settings.hooks || !absoluteRunner) return false;
if (!opts) opts = {};
@@ -680,7 +686,8 @@ function rewriteLegacyManagedNodeHookCommands(settings, absoluteRunner, opts) {
if (platform !== 'win32' || hadPowerShellCallOperator) continue;
}
h.command = formatHookCommandForShell(`${absoluteRunner} ${scriptToken}`, opts);
const safeScriptToken = formatManagedHookScriptToken(scriptPath, opts) || scriptToken;
h.command = formatHookCommandForShell(`${absoluteRunner} ${safeScriptToken}`, opts);
changed = true;
}
}