@@ -192,16 +192,16 @@ export class SystemUtilities {
192
192
* @param doLog log failures
193
193
* @param expected output must contain this string
194
194
*/
195
- public static async tryRun ( p : string , args : string [ ] , doLog ?: boolean , expected ?: string ) : Promise < boolean > {
196
- const proc = new ChildProcess ( p , args )
195
+ public static async tryRun ( p : string , args : string [ ] , logging : 'yes' | 'no' | 'noresult' = 'yes' , expected ?: string ) : Promise < boolean > {
196
+ const proc = new ChildProcess ( p , args , { logging : 'no' } )
197
197
const r = await proc . run ( )
198
- if ( r . exitCode === 0 && ( expected === undefined || r . stdout . includes ( expected ) ) ) {
199
- return true
198
+ const ok = r . exitCode === 0 && ( expected === undefined || r . stdout . includes ( expected ) )
199
+ if ( logging === 'noresult' ) {
200
+ getLogger ( ) . info ( 'tryRun: %s: %s' , ok ? 'ok' : 'failed' , proc )
201
+ } else if ( logging !== 'no' ) {
202
+ getLogger ( ) . info ( 'tryRun: %s: %s %O' , ok ? 'ok' : 'failed' , proc , proc . result ( ) )
200
203
}
201
- if ( doLog ) {
202
- getLogger ( ) . warn ( 'tryRun: failed: %s %O' , proc , proc . result ( ) )
203
- }
204
- return false
204
+ return ok
205
205
}
206
206
207
207
/**
@@ -263,7 +263,7 @@ export class SystemUtilities {
263
263
264
264
for ( const tsc of tscPaths ) {
265
265
// Try to run "tsc -v".
266
- if ( await SystemUtilities . tryRun ( tsc , [ '-v' ] , false , 'Version' ) ) {
266
+ if ( await SystemUtilities . tryRun ( tsc , [ '-v' ] , 'yes' , 'Version' ) ) {
267
267
return tsc
268
268
}
269
269
}
@@ -292,7 +292,7 @@ export class SystemUtilities {
292
292
if ( ! p || ( 'ssh' !== p && ! fs . existsSync ( p ) ) ) {
293
293
continue
294
294
}
295
- if ( await SystemUtilities . tryRun ( p , [ '-G' , 'x' ] ) ) {
295
+ if ( await SystemUtilities . tryRun ( p , [ '-G' , 'x' ] , 'noresult' /* "ssh -G" prints quasi-sensitive info. */ ) ) {
296
296
SystemUtilities . sshPath = p
297
297
return p
298
298
}
0 commit comments