@@ -4,7 +4,6 @@ import { Log } from "../util/log"
44import path from "path"
55import { Filesystem } from "../util/filesystem"
66import { NamedError } from "@opencode-ai/util/error"
7- import { text } from "node:stream/consumers"
87import { Lock } from "../util/lock"
98import { PackageRegistry } from "./registry"
109import { proxied } from "@/util/proxied"
@@ -13,32 +12,29 @@ import { Process } from "../util/process"
1312export namespace BunProc {
1413 const log = Log . create ( { service : "bun" } )
1514
16- export async function run ( cmd : string [ ] , options ?: Process . Options ) {
15+ export async function run ( cmd : string [ ] , options ?: Process . RunOptions ) {
16+ const full = [ which ( ) , ...cmd ]
1717 log . info ( "running" , {
18- cmd : [ which ( ) , ... cmd ] ,
18+ cmd : full ,
1919 ...options ,
2020 } )
21- const result = Process . spawn ( [ which ( ) , ...cmd ] , {
22- ...options ,
23- stdout : "pipe" ,
24- stderr : "pipe" ,
21+ const result = await Process . run ( full , {
22+ cwd : options ?. cwd ,
23+ abort : options ?. abort ,
24+ kill : options ?. kill ,
25+ timeout : options ?. timeout ,
26+ nothrow : options ?. nothrow ,
2527 env : {
2628 ...process . env ,
2729 ...options ?. env ,
2830 BUN_BE_BUN : "1" ,
2931 } ,
3032 } )
31- const code = await result . exited
32- const stdout = result . stdout ? await text ( result . stdout ) : undefined
33- const stderr = result . stderr ? await text ( result . stderr ) : undefined
3433 log . info ( "done" , {
35- code,
36- stdout,
37- stderr,
34+ code : result . code ,
35+ stdout : result . stdout . toString ( ) ,
36+ stderr : result . stderr . toString ( ) ,
3837 } )
39- if ( code !== 0 ) {
40- throw new Error ( `Command failed with exit code ${ code } ` )
41- }
4238 return result
4339 }
4440
0 commit comments