@@ -10,7 +10,7 @@ const treeKill = require('tree-kill');
10
10
interface ExecOptions {
11
11
silent ?: boolean ;
12
12
waitForMatch ?: RegExp ;
13
- env ?: { [ varname : string ] : string } ;
13
+ env ?: { [ varname : string ] : string | undefined } ;
14
14
stdin ?: string ;
15
15
cwd ?: string ;
16
16
}
@@ -59,7 +59,8 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
59
59
}
60
60
61
61
const childProcess = child_process . spawn ( cmd , args , spawnOptions ) ;
62
- childProcess . stdout . on ( 'data' , ( data : Buffer ) => {
62
+ // @ts -ignore
63
+ childProcess . stdout ! . on ( 'data' , ( data : Buffer ) => {
63
64
stdout += data . toString ( 'utf-8' ) ;
64
65
if ( options . silent ) {
65
66
return ;
@@ -70,7 +71,8 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
70
71
. filter ( ( line ) => line !== '' )
71
72
. forEach ( ( line ) => console . log ( ' ' + line ) ) ;
72
73
} ) ;
73
- childProcess . stderr . on ( 'data' , ( data : Buffer ) => {
74
+ // @ts -ignore
75
+ childProcess . stderr ! . on ( 'data' , ( data : Buffer ) => {
74
76
stderr += data . toString ( 'utf-8' ) ;
75
77
if ( options . silent ) {
76
78
return ;
@@ -116,13 +118,15 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
116
118
117
119
if ( options . waitForMatch ) {
118
120
const match = options . waitForMatch ;
119
- childProcess . stdout . on ( 'data' , ( data : Buffer ) => {
121
+ // @ts -ignore
122
+ childProcess . stdout ! . on ( 'data' , ( data : Buffer ) => {
120
123
if ( data . toString ( ) . match ( match ) ) {
121
124
resolve ( { stdout, stderr } ) ;
122
125
matched = true ;
123
126
}
124
127
} ) ;
125
- childProcess . stderr . on ( 'data' , ( data : Buffer ) => {
128
+ // @ts -ignore
129
+ childProcess . stderr ! . on ( 'data' , ( data : Buffer ) => {
126
130
if ( data . toString ( ) . match ( match ) ) {
127
131
resolve ( { stdout, stderr } ) ;
128
132
matched = true ;
@@ -132,8 +136,8 @@ function _exec(options: ExecOptions, cmd: string, args: string[]): Promise<Proce
132
136
133
137
// Provide input to stdin if given.
134
138
if ( options . stdin ) {
135
- childProcess . stdin . write ( options . stdin ) ;
136
- childProcess . stdin . end ( ) ;
139
+ childProcess . stdin ! . write ( options . stdin ) ;
140
+ childProcess . stdin ! . end ( ) ;
137
141
}
138
142
} ) ;
139
143
}
@@ -155,13 +159,15 @@ export function waitForAnyProcessOutputToMatch(
155
159
new Promise ( ( resolve ) => {
156
160
let stdout = '' ;
157
161
let stderr = '' ;
158
- childProcess . stdout . on ( 'data' , ( data : Buffer ) => {
162
+ // @ts -ignore
163
+ childProcess . stdout ! . on ( 'data' , ( data : Buffer ) => {
159
164
stdout += data . toString ( ) ;
160
165
if ( data . toString ( ) . match ( match ) ) {
161
166
resolve ( { stdout, stderr } ) ;
162
167
}
163
168
} ) ;
164
- childProcess . stderr . on ( 'data' , ( data : Buffer ) => {
169
+ // @ts -ignore
170
+ childProcess . stderr ! . on ( 'data' , ( data : Buffer ) => {
165
171
stderr += data . toString ( ) ;
166
172
if ( data . toString ( ) . match ( match ) ) {
167
173
resolve ( { stdout, stderr } ) ;
@@ -189,7 +195,7 @@ export function silentExec(cmd: string, ...args: string[]) {
189
195
export function execWithEnv (
190
196
cmd : string ,
191
197
args : string [ ] ,
192
- env : { [ varname : string ] : string } ,
198
+ env : { [ varname : string ] : string | undefined } ,
193
199
stdin ?: string ,
194
200
) {
195
201
return _exec ( { env, stdin } , cmd , args ) ;
@@ -198,7 +204,7 @@ export function execWithEnv(
198
204
export async function execAndCaptureError (
199
205
cmd : string ,
200
206
args : string [ ] ,
201
- env ?: { [ varname : string ] : string } ,
207
+ env ?: { [ varname : string ] : string | undefined } ,
202
208
stdin ?: string ,
203
209
) : Promise < Error > {
204
210
try {
0 commit comments