fix: stabilize windows hook and claw tests

This commit is contained in:
Affaan Mustafa
2026-03-05 12:37:24 -08:00
parent 5fe40f4a63
commit d1f44e89e2
3 changed files with 19 additions and 18 deletions

View File

@@ -100,11 +100,15 @@ function runHookWithInput(scriptPath, input = {}, env = {}, timeoutMs = 10000) {
function runHookCommand(command, input = {}, env = {}, timeoutMs = 10000) {
return new Promise((resolve, reject) => {
const isWindows = process.platform === 'win32';
const mergedEnv = { ...process.env, CLAUDE_PLUGIN_ROOT: REPO_ROOT, ...env };
const resolvedCommand = isWindows
? command.replace(/\$\{([A-Z_][A-Z0-9_]*)\}/g, (_, name) => String(mergedEnv[name] || ''))
: command;
const shell = isWindows ? 'cmd' : 'bash';
const shellArgs = isWindows ? ['/d', '/s', '/c', command] : ['-lc', command];
const shellArgs = isWindows ? ['/d', '/s', '/c', resolvedCommand] : ['-lc', resolvedCommand];
const proc = spawn(shell, shellArgs, {
env: { ...process.env, CLAUDE_PLUGIN_ROOT: REPO_ROOT, ...env },
env: mergedEnv,
stdio: ['pipe', 'pipe', 'pipe']
});