@@ -17,6 +17,7 @@ import { major, minor } from "semver";
17
17
import { getExitCode } from "./getExitCode.js" ;
18
18
import { applyProfile , profiles } from "./profiles.js" ;
19
19
import { write } from "./write.js" ;
20
+ import { Writable } from "stream" ;
20
21
21
22
const packageJson = createRequire ( import . meta. url ) ( "../package.json" ) ;
22
23
const version = packageJson . version ;
@@ -99,8 +100,13 @@ particularly ESM-related module resolution issues.`,
99
100
applyProfile ( opts . profile , opts ) ;
100
101
}
101
102
103
+ let out : Writable = process . stdout ;
102
104
if ( opts . quiet ) {
103
- console . log = ( ) => { } ;
105
+ out = new ( class extends Writable {
106
+ _write ( _chunk : any , _encoding : BufferEncoding , callback : ( error ? : Error | null ) = > void ) {
107
+ callback ( ) ;
108
+ }
109
+ } ) ( ) ;
104
110
}
105
111
106
112
if ( ! opts . color ) {
@@ -224,7 +230,7 @@ particularly ESM-related module resolution issues.`,
224
230
result . problems = groupProblemsByKind ( analysis . problems ) ;
225
231
}
226
232
227
- await write ( JSON . stringify ( result , undefined , 2 ) + "\n" ) ;
233
+ await write ( JSON . stringify ( result , undefined , 2 ) , out ) ;
228
234
229
235
if ( deleteTgz ) {
230
236
await unlink ( deleteTgz ) ;
@@ -238,12 +244,12 @@ particularly ESM-related module resolution issues.`,
238
244
return ;
239
245
}
240
246
241
- console . log ( ) ;
247
+ await write ( "" , out ) ;
242
248
if ( analysis . types ) {
243
- console . log ( await render . typed ( analysis , opts ) ) ;
249
+ await write ( await render . typed ( analysis , opts ) , out ) ;
244
250
process . exitCode = getExitCode ( analysis , opts ) ;
245
251
} else {
246
- console . log ( render . untyped ( analysis as core . UntypedResult ) ) ;
252
+ await write ( render . untyped ( analysis as core . UntypedResult ) , out ) ;
247
253
}
248
254
249
255
if ( deleteTgz ) {
0 commit comments