MCPcopy
hub / github.com/aws-samples/aws-cdk-examples / runStep

Function runStep

scripts/build-toolkit/src/runner.ts:4–36  ·  view source on GitHub ↗
(name: StepName, cmd: string, args: string[], cwd: string, timeoutMs = 300_000)

Source from the content-addressed store, hash-verified

2import { StepResult, StepName } from './types';
3
4export function runStep(name: StepName, cmd: string, args: string[], cwd: string, timeoutMs = 300_000): Promise<StepResult> {
5 const start = Date.now();
6 return new Promise((resolve) => {
7 const proc = spawn(cmd, args, {
8 cwd,
9 stdio: ['ignore', 'pipe', 'pipe'],
10 timeout: timeoutMs,
11 env: { ...process.env },
12 });
13
14 const chunks: Buffer[] = [];
15 proc.stdout.on('data', (d) => chunks.push(d));
16 proc.stderr.on('data', (d) => chunks.push(d));
17
18 proc.on('close', (code) => {
19 resolve({
20 name,
21 success: code === 0,
22 durationMs: Date.now() - start,
23 output: Buffer.concat(chunks).toString().slice(-8000), // keep last 8k
24 });
25 });
26
27 proc.on('error', (err) => {
28 resolve({
29 name,
30 success: false,
31 durationMs: Date.now() - start,
32 output: err.message,
33 });
34 });
35 });
36}

Callers 5

buildTypescriptFunction · 0.90
buildPythonFunction · 0.90
buildJavaFunction · 0.90
buildGoFunction · 0.90
buildCsharpFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected