MCPcopy
hub / github.com/graphile/starter / runSync

Function runSync

scripts/lib/run.js:3–46  ·  view source on GitHub ↗
(cmd, args, options = {})

Source from the content-addressed store, hash-verified

1const { spawnSync } = require("child_process");
2
3const runSync = (cmd, args, options = {}) => {
4 const result = spawnSync(cmd, args, {
5 stdio: ["inherit", "inherit", "inherit"],
6 windowsHide: true,
7 ...options,
8 env: {
9 ...process.env,
10 YARN_SILENT: "1",
11 npm_config_loglevel: "silent",
12 ...options.env,
13 },
14 });
15
16 const { error, status, signal, stderr, stdout } = result;
17
18 if (error) {
19 throw error;
20 }
21
22 if (status || signal) {
23 if (stdout) {
24 console.log(stdout.toString("utf8"));
25 }
26 if (stderr) {
27 console.error(stderr.toString("utf8"));
28 }
29 if (status) {
30 process.exitCode = status;
31 throw new Error(
32 `Process exited with status '${status}' (running '${cmd} ${
33 args ? args.join(" ") : ""
34 }')`
35 );
36 } else {
37 throw new Error(
38 `Process exited due to signal '${signal}' (running '${cmd} ${
39 args ? args.join(" ") : null
40 }')`
41 );
42 }
43 }
44
45 return result;
46};
47
48exports.runSync = runSync;

Callers 4

setup_db.jsFile · 0.85
setup_env.jsFile · 0.85
mainFunction · 0.85

Calls 1

spawnSyncFunction · 0.85

Tested by

no test coverage detected