MCPcopy Create free account
hub / github.com/6pac/SlickGrid / spawnStreaming

Function spawnStreaming

scripts/child-process.mjs:131–169  ·  view source on GitHub ↗
(
  command,
  args,
  opts,
  prefix,
  cmdDryRun = false
)

Source from the content-addressed store, hash-verified

129 */
130// istanbul ignore next
131export function spawnStreaming(
132 command,
133 args,
134 opts,
135 prefix,
136 cmdDryRun = false
137) {
138 const options = {
139 ...opts,
140 nodeOptions: {
141 stdio: ['pipe', 'inherit', 'inherit'],
142 },
143 };
144
145 if (cmdDryRun) {
146 return logExecDryRunCommand(command, args);
147 }
148 const spawned = spawnProcess(command, args, options, cmdDryRun);
149
150 const stdoutOpts = {};
151 const stderrOpts = {}; // mergeMultiline causes escaped newlines :P
152
153 if (prefix) {
154 const color = c['magenta'];
155 stdoutOpts.tag = `${color.bold(prefix)}:`;
156 stderrOpts.tag = `${color(prefix)}:`;
157 }
158
159 // Avoid 'Possible EventEmitter memory leak detected' warning due to piped stdio
160 if (children.size > process.stdout.listenerCount('close')) {
161 process.stdout.setMaxListeners(children.size);
162 process.stderr.setMaxListeners(children.size);
163 }
164
165 spawned.stdout?.pipe(createLogPrefixer(stdoutOpts)).pipe(process.stdout);
166 spawned.stderr?.pipe(createLogPrefixer(stderrOpts)).pipe(process.stderr);
167
168 return wrapError(spawned);
169}
170
171// --
172// private functions

Callers 3

publishPackageFunction · 0.90
runProdBuildWithTypesFunction · 0.90
buildAllSassFilesFunction · 0.90

Calls 5

logExecDryRunCommandFunction · 0.85
spawnProcessFunction · 0.85
createLogPrefixerFunction · 0.85
wrapErrorFunction · 0.85
pipeMethod · 0.80

Tested by

no test coverage detected