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

Function spawnSync

lib/child_process.js:867–913  ·  view source on GitHub ↗

* Spawns a new process synchronously using the given `file`. * @param {string} file * @param {string[]} [args] * @param {{ * cwd?: string | URL; * input?: string | Buffer | TypedArray | DataView; * argv0?: string; * stdio?: string | Array; * env?: Record ; * uid?:

(file, args, options)

Source from the content-addressed store, hash-verified

865 * }}
866 */
867function spawnSync(file, args, options) {
868 options = {
869 __proto__: null,
870 maxBuffer: MAX_BUFFER,
871 ...normalizeSpawnArguments(file, args, options),
872 };
873
874 debug('spawnSync', options);
875
876 // Validate the timeout, if present.
877 validateTimeout(options.timeout);
878
879 // Validate maxBuffer, if present.
880 validateMaxBuffer(options.maxBuffer);
881
882 // Validate and translate the kill signal, if present.
883 options.killSignal = sanitizeKillSignal(options.killSignal);
884
885 options.stdio = getValidStdio(options.stdio || 'pipe', true).stdio;
886
887 if (options.input) {
888 const stdin = options.stdio[0] = { ...options.stdio[0] };
889 stdin.input = options.input;
890 }
891
892 // We may want to pass data in on any given fd, ensure it is a valid buffer
893 for (let i = 0; i < options.stdio.length; i++) {
894 const input = options.stdio[i]?.input;
895 if (input != null) {
896 const pipe = options.stdio[i] = { ...options.stdio[i] };
897 if (isArrayBufferView(input)) {
898 pipe.input = input;
899 } else if (typeof input === 'string') {
900 pipe.input = Buffer.from(input, options.encoding);
901 } else {
902 throw new ERR_INVALID_ARG_TYPE(`options.stdio[${i}]`,
903 ['Buffer',
904 'TypedArray',
905 'DataView',
906 'string'],
907 input);
908 }
909 }
910 }
911
912 return child_process.spawnSync(options);
913}
914
915
916function checkExecSyncError(ret, args, cmd) {

Callers 15

execFileSyncFunction · 0.70
execSyncFunction · 0.70
spawnCopyDeepSyncFunction · 0.50
runNPMPackageTestsFunction · 0.50
spawnProcessFunction · 0.50
spawnProcessFunction · 0.50
spawnProcessFunction · 0.50
buildSnapshotFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50

Calls 7

normalizeSpawnArgumentsFunction · 0.85
validateMaxBufferFunction · 0.85
sanitizeKillSignalFunction · 0.85
getValidStdioFunction · 0.85
validateTimeoutFunction · 0.70
debugFunction · 0.50
fromMethod · 0.45

Tested by 2

testFunction · 0.40
testFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…