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

Function run

test/sequential/test-watch-mode.mjs:43–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 let stdout = [];
42
43 const run = () => {
44 args.unshift('--no-warnings');
45 child = spawn(execPath, args, { encoding: 'utf8', stdio: 'pipe', ...options });
46
47 child.stderr.on('data', (data) => {
48 stderr += data;
49 });
50
51 const rl = createInterface({ input: child.stdout });
52 rl.on('line', (data) => {
53 if (!data.startsWith('Waiting for graceful termination') && !data.startsWith('Gracefully restarted')) {
54 stdout.push(data);
55 if (data.startsWith(completed)) {
56 future.resolve({ stderr, stdout });
57 future = Promise.withResolvers();
58 stdout = [];
59 stderr = '';
60 } else if (data.startsWith('Failed running')) {
61 const settle = () => {
62 if (shouldFail) {
63 future.resolve({ stderr, stdout });
64 } else {
65 future.reject({ stderr, stdout });
66 }
67 future = Promise.withResolvers();
68 stdout = [];
69 stderr = '';
70 };
71 // If stderr is empty, wait for it to receive data before settling.
72 // This handles the race condition where stdout arrives before stderr.
73 if (stderr === '') {
74 child.stderr.once('data', settle);
75 } else {
76 settle();
77 }
78 }
79 }
80 });
81 };
82
83 return {
84 async done() {

Callers 1

restartFunction · 0.70

Calls 8

unshiftMethod · 0.80
settleFunction · 0.70
spawnFunction · 0.50
createInterfaceFunction · 0.50
onMethod · 0.45
pushMethod · 0.45
resolveMethod · 0.45
onceMethod · 0.45

Tested by

no test coverage detected