Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix: normalize hook command execution in integration tests

Affaan Mustafa1f8b3eaba7b3
diff --git a/tests/integration/hooks.test.js b/tests/integration/hooks.test.js
index 17df089fa..90e498028 100644
--- a/tests/integration/hooks.test.js
+++ b/tests/integration/hooks.test.js
@@ -101,16 +101,28 @@ 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 resolvedCommand = command.replace(
+ /\$\{([A-Z_][A-Z0-9_]*)\}/g,
+ (_, name) => String(mergedEnv[name] || '')
+ );
+
+ const nodeMatch = resolvedCommand.match(/^node\s+"([^"]+)"\s*(.*)$/);
+ const useDirectNodeSpawn = Boolean(nodeMatch);
const shell = isWindows ? 'cmd' : 'bash';
const shellArgs = isWindows ? ['/d', '/s', '/c', resolvedCommand] : ['-lc', resolvedCommand];
-
- const proc = spawn(shell, shellArgs, {
- env: mergedEnv,
- stdio: ['pipe', 'pipe', 'pipe']
- });
+ const nodeArgs = nodeMatch
+ ? [
+ nodeMatch[1],
+ ...Array.from(
+ nodeMatch[2].matchAll(/"([^"]*)"|(\S+)/g),
+ m => m[1] !== undefined ? m[1] : m[2]
+ )
+ ]
+ : [];
+
+ const proc = useDirectNodeSpawn
+ ? spawn('node', nodeArgs, { env: mergedEnv, stdio: ['pipe', 'pipe', 'pipe'] })
+ : spawn(shell, shellArgs, { env: mergedEnv, stdio: ['pipe', 'pipe', 'pipe'] });
let stdout = '';
let stderr = '';