File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import * as render from "./render/index.js";
16
16
import { major , minor } from "semver" ;
17
17
import { getExitCode } from "./getExitCode.js" ;
18
18
import { applyProfile , profiles } from "./profiles.js" ;
19
+ import { write } from "./write.js" ;
19
20
20
21
const packageJson = createRequire ( import . meta. url ) ( "../package.json" ) ;
21
22
const version = packageJson . version ;
@@ -223,7 +224,7 @@ particularly ESM-related module resolution issues.`,
223
224
result . problems = groupProblemsByKind ( analysis . problems ) ;
224
225
}
225
226
226
- console . log ( JSON . stringify ( result , undefined , 2 ) ) ;
227
+ await write ( JSON . stringify ( result , undefined , 2 ) + "\n" ) ;
227
228
228
229
if ( deleteTgz ) {
229
230
await unlink ( deleteTgz ) ;
Original file line number Diff line number Diff line change
1
+ import { Readable , Writable } from "node:stream" ;
2
+ import { pipeline } from "node:stream/promises" ;
3
+
4
+ // JSON output is often longer than 64 kb, so we need to use streams to write it to stdout
5
+ // in order to avoid truncation when piping to other commands.
6
+ export function write ( data : string , out : Writable = process . stdout ) : Promise < void > {
7
+ const stream = new Readable ( ) ;
8
+ stream . push ( data ) ;
9
+ stream . push ( null ) ;
10
+ return pipeline ( stream , out ) ;
11
+ }
You can’t perform that action at this time.
0 commit comments