MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / spawn

Function spawn

scripts/devtools_build.mjs:50–94  ·  view source on GitHub ↗

* Promisified wrapper around `child_process.spawn()`. * * In addition to forwarding the `options` to `child_process.spawn()`, it'll also * set the `shell` option to `true`, to ensure that on Windows we can correctly * invoke `.bat` files (necessary for the Python3 wrapper script). * * @param {

(command, args, options = {})

Source from the content-addressed store, hash-verified

48 * @returns {Promise<{stdout: string, stderr: string}>}
49 */
50function spawn(command, args, options = {}) {
51 return new Promise((resolve, reject) => {
52 let child;
53 if (os.platform() === 'win32') {
54 child = childProcess.spawn(
55 process.env.ComSpec ?? 'cmd.exe',
56 ['/c', command, ...args],
57 options,
58 );
59 } else {
60 child = childProcess.spawn(command, args, options);
61 }
62
63 let stdout = '';
64 let stderr = '';
65
66 child.stdout.on('data', data => {
67 stdout += data.toString();
68 });
69
70 child.stderr.on('data', data => {
71 stderr += data.toString();
72 });
73
74 child.on('exit', (code, signal) => {
75 if (signal) {
76 reject(
77 new SpawnError(
78 `Process terminated due to signal ${signal}`,
79 stderr,
80 stdout,
81 ),
82 );
83 } else if (code) {
84 reject(
85 new SpawnError(`Process exited with code ${code}`, stderr, stdout),
86 );
87 } else {
88 resolve({ stdout, stderr });
89 }
90 });
91
92 child.on('error', reject);
93 });
94}
95
96/**
97 * Representation of the feature set that is configured for Chrome. This

Callers 9

startServerFunction · 0.85
prepareBuildFunction · 0.85
gnArgsForTargetFunction · 0.85
gnRefsForTargetFunction · 0.85
buildFunction · 0.85
bisect.mjsFile · 0.85
getLitAnalyzerResultFunction · 0.85
runTypeCheckFunction · 0.85
runProcessFunction · 0.85

Calls 3

onMethod · 0.80
platformMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected