@@ -3,21 +3,28 @@ import { BENCHMARK_DIR_NAME, GENERATED_DIR_NAME } from '@/constants/path'
33import { cleanDir } from '@/utils/clean-dir'
44import { extractFileName } from '@/utils/extract-file-name'
55import { writeFile } from '@/utils/write-file'
6+ import { Chunk } from '@effect/schema/Schema'
67import { spawn } from 'child_process'
78import * as fs from 'node:fs'
89import * as path from 'node:path'
910
1011async function spawnProcess ( command : string , args : string [ ] , onStdout ?: ( chunk : Buffer ) => void ) {
1112 console . log ( 'Running command:' , '\x1b[36m%s\x1b[0m' , command , args . join ( ' ' ) )
1213
14+ let buffer = Buffer . from ( '' )
15+
1316 return new Promise < void > ( ( resolve , reject ) => {
1417 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+ } )
1622 else proc . stdout . pipe ( process . stdout )
1723
1824 proc . stderr . pipe ( process . stderr )
1925 proc . on ( 'close' , ( code ) => {
2026 if ( code === 0 ) {
27+ onStdout ?.( buffer )
2128 resolve ( )
2229 } else {
2330 reject ( code )
@@ -50,7 +57,7 @@ async function evaluate(attempt: number, options?: { enableTracing?: boolean })
5057 `pnpm` ,
5158 [ 'tsc' , '--noEmit' , '--skipLibCheck' , '--extendedDiagnostics' , ...traceOptions , srcPath ] ,
5259 ( content ) => {
53- const contentString = content . toString ( )
60+ const contentString = content . toString ( 'utf-8' )
5461 writeFile ( destPath , contentString )
5562 }
5663 )
0 commit comments