cloudaxe-opencode/packages/opencode/src/cli/bootstrap.ts

18 lines
485 B
TypeScript
Raw Normal View History

import { Instance } from "../project/instance"
import { InstanceRuntime } from "../project/instance-runtime"
import { WithInstance } from "../project/with-instance"
2025-06-27 15:29:20 +00:00
export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
return WithInstance.provide({
directory,
fn: async () => {
try {
const result = await cb()
return result
} finally {
await InstanceRuntime.disposeInstance(Instance.current)
}
},
2025-06-27 15:29:20 +00:00
})
}