MCPcopy Create free account
hub / github.com/KnockOutEZ/wigolo / runShellScript

Function runShellScript

tests/integration/repl-e2e.test.ts:105–129  ·  view source on GitHub ↗
(
  lines: string[],
  args: string[],
  historyPath: string,
)

Source from the content-addressed store, hash-verified

103// The history path is redirected to a tmp file so we can assert a piped
104// session leaves ZERO history behind.
105function runShellScript(
106 lines: string[],
107 args: string[],
108 historyPath: string,
109): Promise<{ stdout: string; stderr: string; exitCode: number }> {
110 return new Promise((resolve, reject) => {
111 const child = spawn('node', [BIN_PATH, 'shell', ...args], {
112 env: {
113 ...process.env,
114 LOG_LEVEL: 'error',
115 WIGOLO_DATA_DIR: join(import.meta.dirname, '..', 'fixtures', 'repl-test-data'),
116 WIGOLO_SHELL_HISTORY_PATH: historyPath,
117 },
118 stdio: ['pipe', 'pipe', 'pipe'],
119 });
120 let stdout = '';
121 let stderr = '';
122 child.stdout.on('data', (d: Buffer) => { stdout += d.toString(); });
123 child.stderr.on('data', (d: Buffer) => { stderr += d.toString(); });
124 child.on('error', reject);
125 child.on('close', (code) => resolve({ stdout, stderr, exitCode: code ?? 1 }));
126 child.stdin.write(lines.join('\n') + '\n');
127 child.stdin.end();
128 });
129}
130
131describe('REPL NDJSON scripting', () => {
132 // CONTRACT (as implemented):

Callers 1

repl-e2e.test.tsFile · 0.85

Calls 5

resolveFunction · 0.85
toStringMethod · 0.80
writeMethod · 0.80
endMethod · 0.80
onMethod · 0.65

Tested by

no test coverage detected