| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,6 +89,28 @@ const { | |||
| 89 | 89 | ||
| 90 | 90 | const MAX_BUFFER = 1024 * 1024; | |
| 91 | 91 | ||
| 92 | + /** | ||
| 93 | + * Spawns a new Node.js process + fork. | ||
| 94 | + * @param {string} modulePath | ||
| 95 | + * @param {string[]} [args] | ||
| 96 | + * @param {{ | ||
| 97 | + * cwd?: string; | ||
| 98 | + * detached?: boolean; | ||
| 99 | + * env?: Object; | ||
| 100 | + * execPath?: string; | ||
| 101 | + * execArgv?: string[]; | ||
| 102 | + * gid?: number; | ||
| 103 | + * serialization?: string; | ||
| 104 | + * signal?: AbortSignal; | ||
| 105 | + * killSignal?: string | number; | ||
| 106 | + * silent?: boolean; | ||
| 107 | + * stdio?: Array | string; | ||
| 108 | + * uid?: number; | ||
| 109 | + * windowsVerbatimArguments?: boolean; | ||
| 110 | + * timeout?: number; | ||
| 111 | + * }} [options] | ||
| 112 | + * @returns {ChildProcess} | ||
| 113 | + */ | ||
| 92 | 114 | function fork(modulePath /* , args, options */) { | |
| 93 | 115 | validateString(modulePath, 'modulePath'); | |
| 94 | 116 | ||
@@ -176,7 +198,29 @@ function normalizeExecArgs(command, options, callback) { | |||
| 176 | 198 | }; | |
| 177 | 199 | } | |
| 178 | 200 | ||
| 179 | - | ||
| 201 | + /** | ||
| 202 | + * Spawns a shell executing the given command. | ||
| 203 | + * @param {string} command | ||
| 204 | + * @param {{ | ||
| 205 | + * cmd?: string; | ||
| 206 | + * env?: Object; | ||
| 207 | + * encoding?: string; | ||
| 208 | + * shell?: string; | ||
| 209 | + * signal?: AbortSignal; | ||
| 210 | + * timeout?: number; | ||
| 211 | + * maxBuffer?: number; | ||
| 212 | + * killSignal?: string | number; | ||
| 213 | + * uid?: number; | ||
| 214 | + * gid?: number; | ||
| 215 | + * windowsHide?: boolean; | ||
| 216 | + * }} [options] | ||
| 217 | + * @param {( | ||
| 218 | + * error?: Error, | ||
| 219 | + * stdout?: string | Buffer, | ||
| 220 | + * stderr?: string | Buffer | ||
| 221 | + * ) => any} [callback] | ||
| 222 | + * @returns {ChildProcess} | ||
| 223 | + */ | ||
| 180 | 224 | function exec(command, options, callback) { | |
| 181 | 225 | const opts = normalizeExecArgs(command, options, callback); | |
| 182 | 226 | return module.exports.execFile(opts.file, | |
@@ -207,6 +251,31 @@ ObjectDefineProperty(exec, promisify.custom, { | |||
| 207 | 251 | value: customPromiseExecFunction(exec) | |
| 208 | 252 | }); | |
| 209 | 253 | ||
| 254 | + /** | ||
| 255 | + * Spawns the specified file as a shell. | ||
| 256 | + * @param {string} file | ||
| 257 | + * @param {string[]} [args] | ||
| 258 | + * @param {{ | ||
| 259 | + * cwd?: string; | ||
| 260 | + * env?: Object; | ||
| 261 | + * encoding?: string; | ||
| 262 | + * timeout?: number; | ||
| 263 | + * maxBuffer?: number; | ||
| 264 | + * killSignal?: string | number; | ||
| 265 | + * uid?: number; | ||
| 266 | + * gid?: number; | ||
| 267 | + * windowsHide?: boolean; | ||
| 268 | + * windowsVerbatimArguments?: boolean; | ||
| 269 | + * shell?: boolean | string; | ||
| 270 | + * signal?: AbortSignal; | ||
| 271 | + * }} [options] | ||
| 272 | + * @param {( | ||
| 273 | + * error?: Error, | ||
| 274 | + * stdout?: string | Buffer, | ||
| 275 | + * stderr?: string | Buffer | ||
| 276 | + * ) => any} [callback] | ||
| 277 | + * @returns {ChildProcess} | ||
| 278 | + */ | ||
| 210 | 279 | function execFile(file /* , args, options, callback */) { | |
| 211 | 280 | let args = []; | |
| 212 | 281 | let callback; | |
@@ -596,7 +665,28 @@ function abortChildProcess(child, killSignal) { | |||
| 596 | 665 | } | |
| 597 | 666 | } | |
| 598 | 667 | ||
| 599 | - | ||
| 668 | + /** | ||
| 669 | + * Spawns a new process using the given `file`. | ||
| 670 | + * @param {string} file | ||
| 671 | + * @param {string[]} [args] | ||
| 672 | + * @param {{ | ||
| 673 | + * cwd?: string; | ||
| 674 | + * env?: Object; | ||
| 675 | + * argv0?: string; | ||
| 676 | + * stdio?: Array | string; | ||
| 677 | + * detached?: boolean; | ||
| 678 | + * uid?: number; | ||
| 679 | + * gid?: number; | ||
| 680 | + * serialization?: string; | ||
| 681 | + * shell?: boolean | string; | ||
| 682 | + * windowsVerbatimArguments?: boolean; | ||
| 683 | + * windowsHide?: boolean; | ||
| 684 | + * signal?: AbortSignal; | ||
| 685 | + * timeout?: number; | ||
| 686 | + * killSignal?: string | number; | ||
| 687 | + * }} [options] | ||
| 688 | + * @returns {ChildProcess} | ||
| 689 | + */ | ||
| 600 | 690 | function spawn(file, args, options) { | |
| 601 | 691 | options = normalizeSpawnArguments(file, args, options); | |
| 602 | 692 | validateTimeout(options.timeout); | |
@@ -645,6 +735,36 @@ function spawn(file, args, options) { | |||
| 645 | 735 | return child; | |
| 646 | 736 | } | |
| 647 | 737 | ||
| 738 | + /** | ||
| 739 | + * Spawns a new process synchronously using the given `file`. | ||
| 740 | + * @param {string} file | ||
| 741 | + * @param {string[]} [args] | ||
| 742 | + * @param {{ | ||
| 743 | + * cwd?: string; | ||
| 744 | + * input?: string | Buffer | TypedArray | DataView; | ||
| 745 | + * argv0?: string; | ||
| 746 | + * stdio?: string | Array; | ||
| 747 | + * env?: Object; | ||
| 748 | + * uid?: number; | ||
| 749 | + * gid?: number; | ||
| 750 | + * timeout?: number; | ||
| 751 | + * killSignal?: string | number; | ||
| 752 | + * maxBuffer?: number; | ||
| 753 | + * encoding?: string; | ||
| 754 | + * shell?: boolean | string; | ||
| 755 | + * windowsVerbatimArguments?: boolean; | ||
| 756 | + * windowsHide?: boolean; | ||
| 757 | + * }} [options] | ||
| 758 | + * @returns {{ | ||
| 759 | + * pid: number; | ||
| 760 | + * output: Array; | ||
| 761 | + * stdout: Buffer | string; | ||
| 762 | + * stderr: Buffer | string; | ||
| 763 | + * status: number | null; | ||
| 764 | + * signal: string | null; | ||
| 765 | + * error: Error; | ||
| 766 | + * }} | ||
| 767 | + */ | ||
| 648 | 768 | function spawnSync(file, args, options) { | |
| 649 | 769 | options = { | |
| 650 | 770 | maxBuffer: MAX_BUFFER, | |
@@ -711,7 +831,26 @@ function checkExecSyncError(ret, args, cmd) { | |||
| 711 | 831 | return err; | |
| 712 | 832 | } | |
| 713 | 833 | ||
| 714 | - | ||
| 834 | + /** | ||
| 835 | + * Spawns a file as a shell synchronously. | ||
| 836 | + * @param {string} command | ||
| 837 | + * @param {string[]} [args] | ||
| 838 | + * @param {{ | ||
| 839 | + * cwd?: string; | ||
| 840 | + * input?: string | Buffer | TypedArray | DataView; | ||
| 841 | + * stdio?: string | Array; | ||
| 842 | + * env?: Object; | ||
| 843 | + * uid?: number; | ||
| 844 | + * gid?: number; | ||
| 845 | + * timeout?: number; | ||
| 846 | + * killSignal?: string | number; | ||
| 847 | + * maxBuffer?: number; | ||
| 848 | + * encoding?: string; | ||
| 849 | + * windowsHide?: boolean; | ||
| 850 | + * shell?: boolean | string; | ||
| 851 | + * }} [options] | ||
| 852 | + * @returns {Buffer | string} | ||
| 853 | + */ | ||
| 715 | 854 | function execFileSync(command, args, options) { | |
| 716 | 855 | options = normalizeSpawnArguments(command, args, options); | |
| 717 | 856 | ||
@@ -730,7 +869,25 @@ function execFileSync(command, args, options) { | |||
| 730 | 869 | return ret.stdout; | |
| 731 | 870 | } | |
| 732 | 871 | ||
| 733 | - | ||
| 872 | + /** | ||
| 873 | + * Spawns a shell executing the given `command` synchronously. | ||
| 874 | + * @param {string} command | ||
| 875 | + * @param {{ | ||
| 876 | + * cwd?: string; | ||
| 877 | + * input?: string | Buffer | TypedArray | DataView; | ||
| 878 | + * stdio?: string | Array; | ||
| 879 | + * env?: Object; | ||
| 880 | + * shell?: string; | ||
| 881 | + * uid?: number; | ||
| 882 | + * gid?: number; | ||
| 883 | + * timeout?: number; | ||
| 884 | + * killSignal?: string | number; | ||
| 885 | + * maxBuffer?: number; | ||
| 886 | + * encoding?: string; | ||
| 887 | + * windowsHide?: boolean; | ||
| 888 | + * }} [options] | ||
| 889 | + * @returns {Buffer | string} | ||
| 890 | + */ | ||
| 734 | 891 | function execSync(command, options) { | |
| 735 | 892 | const opts = normalizeExecArgs(command, options, null); | |
| 736 | 893 | const inheritStderr = !opts.options.stdio; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments