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

Function runWriteSucceed

test/sequential/test-watch-mode.mjs:106–153  ·  view source on GitHub ↗
({
  file,
  watchedFile,
  watchFlag = '--watch',
  args = [file],
  completed = 'Completed running',
  restarts = 2,
  options = {},
  shouldFail = false,
})

Source from the content-addressed store, hash-verified

104}
105
106async function runWriteSucceed({
107 file,
108 watchedFile,
109 watchFlag = '--watch',
110 args = [file],
111 completed = 'Completed running',
112 restarts = 2,
113 options = {},
114 shouldFail = false,
115}) {
116 args.unshift('--no-warnings');
117 if (watchFlag !== null) args.unshift(watchFlag);
118 const child = spawn(execPath, args, { encoding: 'utf8', stdio: 'pipe', ...options });
119 let completes = 0;
120 let cancelRestarts = () => {};
121 let stderr = '';
122 const stdout = [];
123
124 child.stderr.on('data', (data) => {
125 stderr += data;
126 });
127
128 try {
129 // Break the chunks into lines
130 for await (const data of createInterface({ input: child.stdout })) {
131 if (!data.startsWith('Waiting for graceful termination') && !data.startsWith('Gracefully restarted')) {
132 stdout.push(data);
133 }
134 if (data.startsWith(completed)) {
135 completes++;
136 if (completes === restarts) {
137 break;
138 }
139 if (completes === 1) {
140 cancelRestarts = restart(watchedFile);
141 }
142 }
143
144 if (!shouldFail && data.startsWith('Failed running')) {
145 break;
146 }
147 }
148 } finally {
149 child.kill();
150 cancelRestarts();
151 }
152 return { stdout, stderr, pid: child.pid };
153}
154
155async function failWriteSucceed({ file, watchedFile }) {
156 const child = spawn(execPath, ['--watch', '--no-warnings', file], { encoding: 'utf8', stdio: 'pipe' });

Callers 1

Calls 8

unshiftMethod · 0.80
killMethod · 0.80
restartFunction · 0.70
cancelRestartsFunction · 0.70
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…