MCPcopy Create free account
hub / github.com/anus-dev/ANUS / run

Method run

integration-tests/test-helper.ts:198–322  ·  view source on GitHub ↗
(
    promptOrOptions: string | { prompt?: string; stdin?: string },
    ...args: string[]
  )

Source from the content-addressed store, hash-verified

196 }
197
198 run(
199 promptOrOptions: string | { prompt?: string; stdin?: string },
200 ...args: string[]
201 ): Promise<string> {
202 let command = `node ${this.bundlePath} --yolo`;
203 const execOptions: {
204 cwd: string;
205 encoding: 'utf-8';
206 input?: string;
207 } = {
208 cwd: this.testDir!,
209 encoding: 'utf-8',
210 };
211
212 if (typeof promptOrOptions === 'string') {
213 command += ` --prompt ${JSON.stringify(promptOrOptions)}`;
214 } else if (
215 typeof promptOrOptions === 'object' &&
216 promptOrOptions !== null
217 ) {
218 if (promptOrOptions.prompt) {
219 command += ` --prompt ${JSON.stringify(promptOrOptions.prompt)}`;
220 }
221 if (promptOrOptions.stdin) {
222 execOptions.input = promptOrOptions.stdin;
223 }
224 }
225
226 command += ` ${args.join(' ')}`;
227
228 const commandArgs = parse(command);
229 const node = commandArgs.shift() as string;
230
231 const child = spawn(node, commandArgs as string[], {
232 cwd: this.testDir!,
233 stdio: 'pipe',
234 env: {
235 ...process.env,
236 // Ensure Grok provider is selected in non-interactive integration tests
237 GROK_API_KEY: process.env.GROK_API_KEY || 'integration-test-key',
238 // Keep NO_COLOR for stable snapshots/parsing
239 NO_COLOR: process.env.NO_COLOR || '1',
240 },
241 });
242
243 let stdout = '';
244 let stderr = '';
245
246 // Handle stdin if provided
247 if (execOptions.input) {
248 child.stdin!.write(execOptions.input);
249 }
250 child.stdin!.end();
251
252 child.stdout!.on('data', (data: Buffer) => {
253 stdout += data;
254 if (env.KEEP_OUTPUT === 'true' || env.VERBOSE === 'true') {
255 process.stdout.write(data);

Calls

no outgoing calls

Tested by

no test coverage detected