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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user