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

Function spawnPromisified

test/common/proxy-server.js:115–152  ·  view source on GitHub ↗
(...args)

Source from the content-addressed store, hash-verified

113exports.createProxyServer = createProxyServer;
114
115function spawnPromisified(...args) {
116 const { spawn } = require('child_process');
117 let stderr = '';
118 let stdout = '';
119
120 const child = spawn(...args);
121 child.stderr.setEncoding('utf8');
122 child.stderr.on('data', (data) => {
123 console.error('[STDERR]', data);
124 stderr += data;
125 });
126 child.stdout.setEncoding('utf8');
127 child.stdout.on('data', (data) => {
128 console.log('[STDOUT]', data);
129 stdout += data;
130 });
131
132 return new Promise((resolve, reject) => {
133 child.on('close', (code, signal) => {
134 console.log('[CLOSE]', code, signal);
135 resolve({
136 code,
137 signal,
138 stderr,
139 stdout,
140 });
141 });
142 child.on('error', (code, signal) => {
143 console.log('[ERROR]', code, signal);
144 reject({
145 code,
146 signal,
147 stderr,
148 stdout,
149 });
150 });
151 });
152}
153
154async function checkProxied(type, envExtension, expectation, cliArgsExtension = []) {
155 const script = type === 'fetch' ? fixtures.path('fetch-and-log.mjs') : fixtures.path('request-and-log.js');

Callers 2

checkProxiedFunction · 0.70
proxy-server.jsFile · 0.70

Calls 8

resolveFunction · 0.70
requireFunction · 0.50
spawnFunction · 0.50
rejectFunction · 0.50
setEncodingMethod · 0.45
onMethod · 0.45
errorMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…