@@ -74,6 +74,28 @@ const {
74
74
75
75
const MAX_BUFFER = 1024 * 1024 ;
76
76
77
+ /**
78
+ * Spawns a new Node.js process + fork.
79
+ * @param {string } modulePath
80
+ * @param {string[] } [args]
81
+ * @param {{
82
+ * cwd?: string;
83
+ * detached?: boolean;
84
+ * env?: Object;
85
+ * execPath?: string;
86
+ * execArgv?: string[];
87
+ * gid?: number;
88
+ * serialization?: string;
89
+ * signal?: AbortSignal;
90
+ * killSignal?: string | number;
91
+ * silent?: boolean;
92
+ * stdio?: Array | string;
93
+ * uid?: number;
94
+ * windowsVerbatimArguments?: boolean;
95
+ * timeout?: number;
96
+ * }} [options]
97
+ * @returns {ChildProcess }
98
+ */
77
99
function fork ( modulePath /* , args, options */ ) {
78
100
validateString ( modulePath , 'modulePath' ) ;
79
101
@@ -161,7 +183,29 @@ function normalizeExecArgs(command, options, callback) {
161
183
} ;
162
184
}
163
185
164
-
186
+ /**
187
+ * Spawns a shell executing the given command.
188
+ * @param {string } command
189
+ * @param {{
190
+ * cmd?: string;
191
+ * env?: Object;
192
+ * encoding?: string;
193
+ * shell?: string;
194
+ * signal?: AbortSignal;
195
+ * timeout?: number;
196
+ * maxBuffer?: number;
197
+ * killSignal?: string | number;
198
+ * uid?: number;
199
+ * gid?: number;
200
+ * windowsHide?: boolean;
201
+ * }} [options]
202
+ * @param {(
203
+ * error?: Error,
204
+ * stdout?: string | Buffer,
205
+ * stderr?: string | Buffer
206
+ * ) => any} [callback]
207
+ * @returns {ChildProcess }
208
+ */
165
209
function exec ( command , options , callback ) {
166
210
const opts = normalizeExecArgs ( command , options , callback ) ;
167
211
return module . exports . execFile ( opts . file ,
@@ -197,6 +241,31 @@ ObjectDefineProperty(exec, promisify.custom, {
197
241
value : customPromiseExecFunction ( exec )
198
242
} ) ;
199
243
244
+ /**
245
+ * Spawns the specified file as a shell.
246
+ * @param {string } file
247
+ * @param {string[] } [args]
248
+ * @param {{
249
+ * cwd?: string;
250
+ * env?: Object;
251
+ * encoding?: string;
252
+ * timeout?: number;
253
+ * maxBuffer?: number;
254
+ * killSignal?: string | number;
255
+ * uid?: number;
256
+ * gid?: number;
257
+ * windowsHide?: boolean;
258
+ * windowsVerbatimArguments?: boolean;
259
+ * shell?: boolean | string;
260
+ * signal?: AbortSignal;
261
+ * }} [options]
262
+ * @param {(
263
+ * error?: Error,
264
+ * stdout?: string | Buffer,
265
+ * stderr?: string | Buffer
266
+ * ) => any} [callback]
267
+ * @returns {ChildProcess }
268
+ */
200
269
function execFile ( file /* , args, options, callback */ ) {
201
270
let args = [ ] ;
202
271
let callback ;
@@ -567,6 +636,28 @@ function normalizeSpawnArguments(file, args, options) {
567
636
}
568
637
569
638
639
+ /**
640
+ * Spawns a new process using the given `file`.
641
+ * @param {string } file
642
+ * @param {string[] } [args]
643
+ * @param {{
644
+ * cwd?: string;
645
+ * env?: Object;
646
+ * argv0?: string;
647
+ * stdio?: Array | string;
648
+ * detached?: boolean;
649
+ * uid?: number;
650
+ * gid?: number;
651
+ * serialization?: string;
652
+ * shell?: boolean | string;
653
+ * windowsVerbatimArguments?: boolean;
654
+ * windowsHide?: boolean;
655
+ * signal?: AbortSignal;
656
+ * timeout?: number;
657
+ * killSignal?: string | number;
658
+ * }} [options]
659
+ * @returns {ChildProcess }
660
+ */
570
661
function spawn ( file , args , options ) {
571
662
const child = new ChildProcess ( ) ;
572
663
@@ -577,6 +668,36 @@ function spawn(file, args, options) {
577
668
return child ;
578
669
}
579
670
671
+ /**
672
+ * Spawns a new process synchronously using the given `file`.
673
+ * @param {string } file
674
+ * @param {string[] } [args]
675
+ * @param {{
676
+ * cwd?: string;
677
+ * input?: string | Buffer | TypedArray | DataView;
678
+ * argv0?: string;
679
+ * stdio?: string | Array;
680
+ * env?: Object;
681
+ * uid?: number;
682
+ * gid?: number;
683
+ * timeout?: number;
684
+ * killSignal?: string | number;
685
+ * maxBuffer?: number;
686
+ * encoding?: string;
687
+ * shell?: boolean | string;
688
+ * windowsVerbatimArguments?: boolean;
689
+ * windowsHide?: boolean;
690
+ * }} [options]
691
+ * @returns {{
692
+ * pid: number;
693
+ * output: Array;
694
+ * stdout: Buffer | string;
695
+ * stderr: Buffer | string;
696
+ * status: number | null;
697
+ * signal: string | null;
698
+ * error: Error;
699
+ * }}
700
+ */
580
701
function spawnSync ( file , args , options ) {
581
702
options = {
582
703
maxBuffer : MAX_BUFFER ,
@@ -643,7 +764,26 @@ function checkExecSyncError(ret, args, cmd) {
643
764
return err ;
644
765
}
645
766
646
-
767
+ /**
768
+ * Spawns a file as a shell synchronously.
769
+ * @param {string } command
770
+ * @param {string[] } [args]
771
+ * @param {{
772
+ * cwd?: string;
773
+ * input?: string | Buffer | TypedArray | DataView;
774
+ * stdio?: string | Array;
775
+ * env?: Object;
776
+ * uid?: number;
777
+ * gid?: number;
778
+ * timeout?: number;
779
+ * killSignal?: string | number;
780
+ * maxBuffer?: number;
781
+ * encoding?: string;
782
+ * windowsHide?: boolean;
783
+ * shell?: boolean | string;
784
+ * }} [options]
785
+ * @returns {Buffer | string }
786
+ */
647
787
function execFileSync ( command , args , options ) {
648
788
options = normalizeSpawnArguments ( command , args , options ) ;
649
789
@@ -661,7 +801,25 @@ function execFileSync(command, args, options) {
661
801
return ret . stdout ;
662
802
}
663
803
664
-
804
+ /**
805
+ * Spawns a shell executing the given `command` synchronously.
806
+ * @param {string } command
807
+ * @param {{
808
+ * cwd?: string;
809
+ * input?: string | Buffer | TypedArray | DataView;
810
+ * stdio?: string | Array;
811
+ * env?: Object;
812
+ * shell?: string;
813
+ * uid?: number;
814
+ * gid?: number;
815
+ * timeout?: number;
816
+ * killSignal?: string | number;
817
+ * maxBuffer?: number;
818
+ * encoding?: string;
819
+ * windowsHide?: boolean;
820
+ * }} [options]
821
+ * @returns {Buffer | string }
822
+ */
665
823
function execSync ( command , options ) {
666
824
const opts = normalizeExecArgs ( command , options , null ) ;
667
825
const inheritStderr = ! opts . options . stdio ;
0 commit comments