MCPcopy
hub / github.com/promptfoo/promptfoo / runEntrypointAsync

Function runEntrypointAsync

test/smoke/cli.test.ts:64–102  ·  view source on GitHub ↗
(
  args: string[],
  options: { cwd?: string; env?: NodeJS.ProcessEnv } = {},
)

Source from the content-addressed store, hash-verified

62}
63
64function runEntrypointAsync(
65 args: string[],
66 options: { cwd?: string; env?: NodeJS.ProcessEnv } = {},
67): Promise<{ stdout: string; stderr: string; exitCode: number }> {
68 return new Promise((resolve, reject) => {
69 const child = spawn('node', [ENTRYPOINT_PATH, ...args], {
70 cwd: options.cwd || ROOT_DIR,
71 env: { ...process.env, ...options.env, NO_COLOR: '1' },
72 });
73
74 let stdout = '';
75 let stderr = '';
76 const timeoutId = setTimeout(() => {
77 child.kill('SIGTERM');
78 reject(new Error(`CLI entrypoint timed out for: ${args.join(' ')}`));
79 }, 30000);
80
81 child.stdout.setEncoding('utf8');
82 child.stdout.on('data', (chunk: string) => {
83 stdout += chunk;
84 });
85 child.stderr.setEncoding('utf8');
86 child.stderr.on('data', (chunk: string) => {
87 stderr += chunk;
88 });
89 child.once('error', (error) => {
90 clearTimeout(timeoutId);
91 reject(error);
92 });
93 child.once('close', (code) => {
94 clearTimeout(timeoutId);
95 resolve({
96 stdout,
97 stderr,
98 exitCode: code ?? 1,
99 });
100 });
101 });
102}
103
104function runGit(args: string[], cwd: string): void {
105 const result = spawnSync('git', args, {

Callers 1

cli.test.tsFile · 0.85

Calls 2

resolveFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…