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

Function runNode

test/sequential/test-watch-mode-watch-flags.mjs:22–49  ·  view source on GitHub ↗
({
  args,
  expectedCompletionLog = 'Completed running',
  options = {},
})

Source from the content-addressed store, hash-verified

20}
21
22async function runNode({
23 args,
24 expectedCompletionLog = 'Completed running',
25 options = {},
26}) {
27 const child = spawn(execPath, args, { encoding: 'utf8', stdio: 'pipe', ...options });
28 let stderr = '';
29 const stdout = [];
30
31 child.stderr.on('data', (data) => {
32 stderr += data;
33 });
34
35 try {
36 // Break the chunks into lines
37 for await (const data of createInterface({ input: child.stdout })) {
38 if (!data.startsWith('Waiting for graceful termination') && !data.startsWith('Gracefully restarted')) {
39 stdout.push(data);
40 }
41 if (data.startsWith(expectedCompletionLog)) {
42 break;
43 }
44 }
45 } finally {
46 child.kill();
47 }
48 return { stdout, stderr, pid: child.pid };
49}
50
51tmpdir.refresh();
52

Callers 1

Calls 5

killMethod · 0.80
spawnFunction · 0.50
createInterfaceFunction · 0.50
onMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…