MCPcopy Create free account
hub / github.com/cloudflare/templates / runCommand

Function runCommand

cli/src/deployLiveDemos.ts:19–45  ·  view source on GitHub ↗
(
	file: string,
	args: string[],
	cwd: string,
	log: string[],
)

Source from the content-addressed store, hash-verified

17];
18
19function runCommand(
20 file: string,
21 args: string[],
22 cwd: string,
23 log: string[],
24): Promise<void> {
25 const command = [file, ...args].join(" ");
26 log.push(`Running: ${command} in ${cwd}`);
27 return new Promise((resolve, reject) => {
28 subprocess.execFile(
29 file,
30 args,
31 { cwd, encoding: "utf-8", maxBuffer: 64 * 1024 * 1024 },
32 (error, stdout, stderr) => {
33 if (stdout) log.push(stdout);
34 if (stderr) log.push(stderr);
35 if (error) {
36 log.push(`✗ Failed: ${command} in ${cwd}`);
37 reject(error);
38 } else {
39 log.push(`✓ Success: ${command}`);
40 resolve();
41 }
42 },
43 );
44 });
45}
46
47// Templates deploy in parallel, so each one's output is buffered and printed
48// as a single block when it finishes.

Callers 1

workerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected