MCPcopy Index your code
hub / github.com/nodejs/node / spawnProcess

Function spawnProcess

benchmark/misc/startup-cli-version.js:24–48  ·  view source on GitHub ↗
(cli, bench, state)

Source from the content-addressed store, hash-verified

22});
23
24function spawnProcess(cli, bench, state) {
25 const cmd = process.execPath || process.argv[0];
26 while (state.finished < state.n) {
27 const child = spawnSync(cmd, [cli, '--version'], {
28 env: { npm_config_loglevel: 'silent', ...process.env },
29 });
30 // Log some information for debugging if it fails, which it shouldn't.
31 if (child.status !== 0) {
32 console.log('---- STDOUT ----');
33 console.log(child.stdout.toString());
34 console.log('---- STDERR ----');
35 console.log(child.stderr.toString());
36 throw new Error(`Child process stopped with exit code ${child.status}`);
37 }
38 state.finished++;
39 if (state.finished === 0) {
40 // Finished warmup.
41 bench.start();
42 }
43
44 if (state.finished === state.n) {
45 bench.end(state.n);
46 }
47 }
48}
49
50function main({ n, cli }) {
51 cli = path.resolve(__dirname, '../../', cli);

Callers 1

mainFunction · 0.70

Calls 5

spawnSyncFunction · 0.50
logMethod · 0.45
toStringMethod · 0.45
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…