@@ -3,21 +3,28 @@ import { BENCHMARK_DIR_NAME, GENERATED_DIR_NAME } from '@/constants/path'
3
3
import { cleanDir } from '@/utils/clean-dir'
4
4
import { extractFileName } from '@/utils/extract-file-name'
5
5
import { writeFile } from '@/utils/write-file'
6
+ import { Chunk } from '@effect/schema/Schema'
6
7
import { spawn } from 'child_process'
7
8
import * as fs from 'node:fs'
8
9
import * as path from 'node:path'
9
10
10
11
async function spawnProcess ( command : string , args : string [ ] , onStdout ?: ( chunk : Buffer ) => void ) {
11
12
console . log ( 'Running command:' , '\x1b[36m%s\x1b[0m' , command , args . join ( ' ' ) )
12
13
14
+ let buffer = Buffer . from ( '' )
15
+
13
16
return new Promise < void > ( ( resolve , reject ) => {
14
17
const proc = spawn ( command , args )
15
- if ( onStdout ) proc . stdout . on ( 'data' , onStdout )
18
+ if ( onStdout )
19
+ proc . stdout . on ( 'data' , ( chunk ) => {
20
+ buffer = Buffer . concat ( [ buffer , chunk ] )
21
+ } )
16
22
else proc . stdout . pipe ( process . stdout )
17
23
18
24
proc . stderr . pipe ( process . stderr )
19
25
proc . on ( 'close' , ( code ) => {
20
26
if ( code === 0 ) {
27
+ onStdout ?.( buffer )
21
28
resolve ( )
22
29
} else {
23
30
reject ( code )
@@ -50,7 +57,7 @@ async function evaluate(attempt: number, options?: { enableTracing?: boolean })
50
57
`pnpm` ,
51
58
[ 'tsc' , '--noEmit' , '--skipLibCheck' , '--extendedDiagnostics' , ...traceOptions , srcPath ] ,
52
59
( content ) => {
53
- const contentString = content . toString ( )
60
+ const contentString = content . toString ( 'utf-8' )
54
61
writeFile ( destPath , contentString )
55
62
}
56
63
)
0 commit comments