@@ -80,6 +80,7 @@ declare var SlowBuffer: {
80
80
81
81
82
82
// Buffer class
83
+ type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex" ;
83
84
interface Buffer extends NodeBuffer { }
84
85
85
86
/**
@@ -227,8 +228,8 @@ declare module NodeJS {
227
228
removeListener ( event : string , listener : Function ) : this;
228
229
removeAllListeners ( event ?: string ) : this;
229
230
}
230
-
231
- export interface MemoryUsage {
231
+
232
+ export interface MemoryUsage {
232
233
rss : number ;
233
234
heapTotal : number ;
234
235
heapUsed : number ;
@@ -945,99 +946,169 @@ declare module "child_process" {
945
946
stdin : stream . Writable ;
946
947
stdout : stream . Readable ;
947
948
stderr : stream . Readable ;
948
- stdio : ( stream . Readable | stream . Writable ) [ ] ;
949
+ stdio : [ stream . Writable , stream . Readable , stream . Readable ] ;
949
950
pid : number ;
950
951
kill ( signal ?: string ) : void ;
951
952
send ( message : any , sendHandle ?: any ) : void ;
952
953
disconnect ( ) : void ;
953
954
unref ( ) : void ;
954
955
}
955
956
956
- export function spawn ( command : string , args ?: string [ ] , options ?: {
957
+ export interface SpawnOptions {
957
958
cwd ?: string ;
958
- stdio ?: any ;
959
- custom ?: any ;
960
959
env ?: any ;
960
+ stdio ?: any ;
961
961
detached ?: boolean ;
962
- } ) : ChildProcess ;
963
- export function exec ( command : string , options : {
962
+ uid ?: number ;
963
+ gid ?: number ;
964
+ shell ?: boolean | string ;
965
+ }
966
+ export function spawn ( command : string , args ?: string [ ] , options ?: SpawnOptions ) : ChildProcess ;
967
+
968
+ export interface ExecOptions {
964
969
cwd ?: string ;
965
- stdio ?: any ;
966
- customFds ?: any ;
967
970
env ?: any ;
968
- encoding ?: string ;
971
+ shell ?: string ;
969
972
timeout ?: number ;
970
973
maxBuffer ?: number ;
971
974
killSignal ?: string ;
972
- } , callback ?: ( error : Error , stdout : Buffer , stderr : Buffer ) => void ) : ChildProcess ;
973
- export function exec ( command : string , callback ?: ( error : Error , stdout : Buffer , stderr : Buffer ) => void ) : ChildProcess ;
974
- export function execFile ( file : string ,
975
- callback ?: ( error : Error , stdout : Buffer , stderr : Buffer ) => void ) : ChildProcess ;
976
- export function execFile ( file : string , args ?: string [ ] ,
977
- callback ?: ( error : Error , stdout : Buffer , stderr : Buffer ) => void ) : ChildProcess ;
978
- export function execFile ( file : string , args ?: string [ ] , options ?: {
975
+ uid ?: number ;
976
+ gid ?: number ;
977
+ }
978
+ export interface ExecOptionsWithStringEncoding extends ExecOptions {
979
+ encoding : BufferEncoding ;
980
+ }
981
+ export interface ExecOptionsWithBufferEncoding extends ExecOptions {
982
+ encoding : string ; // specify `null`.
983
+ }
984
+ export function exec ( command : string , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
985
+ export function exec ( command : string , options : ExecOptionsWithStringEncoding , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
986
+ // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {});
987
+ export function exec ( command : string , options : ExecOptionsWithBufferEncoding , callback ?: ( error : Error , stdout : Buffer , stderr : Buffer ) => void ) : ChildProcess ;
988
+ export function exec ( command : string , options : ExecOptions , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
989
+
990
+ export interface ExecFileOptions {
979
991
cwd ?: string ;
980
- stdio ?: any ;
981
- customFds ?: any ;
982
992
env ?: any ;
983
- encoding ?: string ;
984
993
timeout ?: number ;
985
994
maxBuffer ?: number ;
986
995
killSignal ?: string ;
987
- } , callback ?: ( error : Error , stdout : Buffer , stderr : Buffer ) => void ) : ChildProcess ;
988
- export function fork ( modulePath : string , args ?: string [ ] , options ?: {
996
+ uid ?: number ;
997
+ gid ?: number ;
998
+ }
999
+ export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
1000
+ encoding : BufferEncoding ;
1001
+ }
1002
+ export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
1003
+ encoding : string ; // specify `null`.
1004
+ }
1005
+ export function execFile ( file : string , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
1006
+ export function execFile ( file : string , options ?: ExecFileOptionsWithStringEncoding , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
1007
+ // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {});
1008
+ export function execFile ( file : string , options ?: ExecFileOptionsWithBufferEncoding , callback ?: ( error : Error , stdout : Buffer , stderr : Buffer ) => void ) : ChildProcess ;
1009
+ export function execFile ( file : string , options ?: ExecFileOptions , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
1010
+ export function execFile ( file : string , args ?: string [ ] , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
1011
+ export function execFile ( file : string , args ?: string [ ] , options ?: ExecFileOptionsWithStringEncoding , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
1012
+ // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {});
1013
+ export function execFile ( file : string , args ?: string [ ] , options ?: ExecFileOptionsWithBufferEncoding , callback ?: ( error : Error , stdout : Buffer , stderr : Buffer ) => void ) : ChildProcess ;
1014
+ export function execFile ( file : string , args ?: string [ ] , options ?: ExecFileOptions , callback ?: ( error : Error , stdout : string , stderr : string ) => void ) : ChildProcess ;
1015
+
1016
+ export interface ForkOptions {
989
1017
cwd ?: string ;
990
1018
env ?: any ;
991
1019
execPath ?: string ;
992
1020
execArgv ?: string [ ] ;
993
1021
silent ?: boolean ;
994
1022
uid ?: number ;
995
1023
gid ?: number ;
996
- } ) : ChildProcess ;
997
- export function spawnSync ( command : string , args ?: string [ ] , options ?: {
1024
+ }
1025
+ export function fork ( modulePath : string , args ?: string [ ] , options ?: ForkOptions ) : ChildProcess ;
1026
+
1027
+ export interface SpawnSyncOptions {
998
1028
cwd ?: string ;
999
1029
input ?: string | Buffer ;
1000
1030
stdio ?: any ;
1001
1031
env ?: any ;
1002
1032
uid ?: number ;
1003
1033
gid ?: number ;
1004
1034
timeout ?: number ;
1005
- maxBuffer ?: number ;
1006
1035
killSignal ?: string ;
1036
+ maxBuffer ?: number ;
1007
1037
encoding ?: string ;
1008
- } ) : {
1038
+ shell ?: boolean | string ;
1039
+ }
1040
+ export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
1041
+ encoding : BufferEncoding ;
1042
+ }
1043
+ export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
1044
+ encoding : string ; // specify `null`.
1045
+ }
1046
+ export interface SpawnSyncReturns < T > {
1009
1047
pid : number ;
1010
1048
output : string [ ] ;
1011
- stdout : string | Buffer ;
1012
- stderr : string | Buffer ;
1049
+ stdout : T ;
1050
+ stderr : T ;
1013
1051
status : number ;
1014
1052
signal : string ;
1015
1053
error : Error ;
1016
- } ;
1017
- export function execSync ( command : string , options ?: {
1054
+ }
1055
+ export function spawnSync ( command : string ) : SpawnSyncReturns < Buffer > ;
1056
+ export function spawnSync ( command : string , options ?: SpawnSyncOptionsWithStringEncoding ) : SpawnSyncReturns < string > ;
1057
+ export function spawnSync ( command : string , options ?: SpawnSyncOptionsWithBufferEncoding ) : SpawnSyncReturns < Buffer > ;
1058
+ export function spawnSync ( command : string , options ?: SpawnSyncOptions ) : SpawnSyncReturns < Buffer > ;
1059
+ export function spawnSync ( command : string , args ?: string [ ] , options ?: SpawnSyncOptionsWithStringEncoding ) : SpawnSyncReturns < string > ;
1060
+ export function spawnSync ( command : string , args ?: string [ ] , options ?: SpawnSyncOptionsWithBufferEncoding ) : SpawnSyncReturns < Buffer > ;
1061
+ export function spawnSync ( command : string , args ?: string [ ] , options ?: SpawnSyncOptions ) : SpawnSyncReturns < Buffer > ;
1062
+
1063
+ export interface ExecSyncOptions {
1018
1064
cwd ?: string ;
1019
- input ?: string | Buffer ;
1065
+ input ?: string | Buffer ;
1020
1066
stdio ?: any ;
1021
1067
env ?: any ;
1068
+ shell ?: string ;
1022
1069
uid ?: number ;
1023
1070
gid ?: number ;
1024
1071
timeout ?: number ;
1025
- maxBuffer ?: number ;
1026
1072
killSignal ?: string ;
1073
+ maxBuffer ?: number ;
1027
1074
encoding ?: string ;
1028
- } ) : string | Buffer ;
1029
- export function execFileSync ( command : string , args ?: string [ ] , options ?: {
1075
+ }
1076
+ export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
1077
+ encoding : BufferEncoding ;
1078
+ }
1079
+ export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
1080
+ encoding : string ; // specify `null`.
1081
+ }
1082
+ export function execSync ( command : string ) : Buffer ;
1083
+ export function execSync ( command : string , options ?: ExecSyncOptionsWithStringEncoding ) : string ;
1084
+ export function execSync ( command : string , options ?: ExecSyncOptionsWithBufferEncoding ) : Buffer ;
1085
+ export function execSync ( command : string , options ?: ExecSyncOptions ) : Buffer ;
1086
+
1087
+ export interface ExecFileSyncOptions {
1030
1088
cwd ?: string ;
1031
- input ?: string | Buffer ;
1089
+ input ?: string | Buffer ;
1032
1090
stdio ?: any ;
1033
1091
env ?: any ;
1034
1092
uid ?: number ;
1035
1093
gid ?: number ;
1036
1094
timeout ?: number ;
1037
- maxBuffer ?: number ;
1038
1095
killSignal ?: string ;
1096
+ maxBuffer ?: number ;
1039
1097
encoding ?: string ;
1040
- } ) : string | Buffer ;
1098
+ }
1099
+ export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
1100
+ encoding : BufferEncoding ;
1101
+ }
1102
+ export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
1103
+ encoding : string ; // specify `null`.
1104
+ }
1105
+ export function execFileSync ( command : string ) : Buffer ;
1106
+ export function execFileSync ( command : string , options ?: ExecFileSyncOptionsWithStringEncoding ) : string ;
1107
+ export function execFileSync ( command : string , options ?: ExecFileSyncOptionsWithBufferEncoding ) : Buffer ;
1108
+ export function execFileSync ( command : string , options ?: ExecFileSyncOptions ) : Buffer ;
1109
+ export function execFileSync ( command : string , args ?: string [ ] , options ?: ExecFileSyncOptionsWithStringEncoding ) : string ;
1110
+ export function execFileSync ( command : string , args ?: string [ ] , options ?: ExecFileSyncOptionsWithBufferEncoding ) : Buffer ;
1111
+ export function execFileSync ( command : string , args ?: string [ ] , options ?: ExecFileSyncOptions ) : Buffer ;
1041
1112
}
1042
1113
1043
1114
declare module "url" {
0 commit comments