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

19 lines
522 B
TypeScript
Raw Normal View History

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