MCPcopy Create free account
hub / github.com/garrytan/gstack / runHook

Function runHook

test/hook-scripts.test.ts:11–24  ·  view source on GitHub ↗
(scriptPath: string, input: object, env?: Record<string, string>)

Source from the content-addressed store, hash-verified

9const FREEZE_SCRIPT = path.join(ROOT, 'freeze', 'bin', 'check-freeze.sh');
10
11function runHook(scriptPath: string, input: object, env?: Record<string, string>): { exitCode: number; output: any; raw: string } {
12 const result = spawnSync('bash', [scriptPath], {
13 input: JSON.stringify(input),
14 stdio: ['pipe', 'pipe', 'pipe'],
15 env: { ...process.env, ...env },
16 timeout: 5000,
17 });
18 const raw = result.stdout.toString().trim();
19 let output: any = {};
20 try {
21 output = JSON.parse(raw);
22 } catch {}
23 return { exitCode: result.status ?? 1, output, raw };
24}
25
26function runHookRaw(scriptPath: string, rawInput: string, env?: Record<string, string>): { exitCode: number; output: any; raw: string } {
27 const result = spawnSync('bash', [scriptPath], {

Callers 1

Calls 1

spawnSyncFunction · 0.85

Tested by

no test coverage detected