mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-30 13:54:01 +00:00
18 lines
418 B
TypeScript
18 lines
418 B
TypeScript
import { InstanceBootstrap } from "../project/bootstrap"
|
|
import { Instance } from "../project/instance"
|
|
|
|
export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
|
|
return Instance.provide({
|
|
directory,
|
|
init: InstanceBootstrap,
|
|
fn: async () => {
|
|
try {
|
|
const result = await cb()
|
|
return result
|
|
} finally {
|
|
await Instance.dispose()
|
|
}
|
|
},
|
|
})
|
|
}
|