2025-09-01 21:15:49 +00:00
|
|
|
import { Instance } from "../project/instance"
|
2026-05-02 23:33:38 +00:00
|
|
|
import { InstanceRuntime } from "../project/instance-runtime"
|
2026-05-03 00:39:20 +00:00
|
|
|
import { WithInstance } from "../project/with-instance"
|
2025-06-27 15:29:20 +00:00
|
|
|
|
2025-09-01 21:15:49 +00:00
|
|
|
export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
|
2026-05-03 00:39:20 +00:00
|
|
|
return WithInstance.provide({
|
2025-09-19 09:11:29 +00:00
|
|
|
directory,
|
|
|
|
|
fn: async () => {
|
2025-10-31 04:57:58 +00:00
|
|
|
try {
|
|
|
|
|
const result = await cb()
|
|
|
|
|
return result
|
|
|
|
|
} finally {
|
2026-05-02 23:33:38 +00:00
|
|
|
await InstanceRuntime.disposeInstance(Instance.current)
|
2025-10-31 04:57:58 +00:00
|
|
|
}
|
2025-09-19 09:11:29 +00:00
|
|
|
},
|
2025-06-27 15:29:20 +00:00
|
|
|
})
|
|
|
|
|
}
|