MCPcopy Create free account
hub / github.com/api3dao/airnode / runCommand

Function runCommand

packages/airnode-examples/test/utils.ts:6–26  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

4import { cliPrint } from '../src';
5
6export const runCommand = (command: string) => {
7 logger.log(`Running command:\n${command}`);
8 const result = spawnSync(command, {
9 shell: true,
10 });
11
12 if (result.status !== 0 || result.error) {
13 throw new Error(`Command failed with non-zero status code. Output:\n${result.stdout.toString()}`);
14 }
15
16 const stderr = result.stderr.toString();
17 if (stderr) {
18 cliPrint.warning(`Stderr output:\n${stderr}`);
19 }
20
21 const stdout = result.stdout.toString();
22 if (stdout) {
23 consoleLog(`Stdout output:\n${stdout}`);
24 }
25 return stdout;
26};
27
28export const runCommandInBackground = (command: string) => {
29 logger.log(`Running background command:\n${command}`);

Callers 1

Calls 1

consoleLogFunction · 0.90

Tested by

no test coverage detected