bootstrap.ts 418 B

1234567891011121314151617
  1. import { InstanceBootstrap } from "../project/bootstrap"
  2. import { Instance } from "../project/instance"
  3. export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
  4. return Instance.provide({
  5. directory,
  6. init: InstanceBootstrap,
  7. fn: async () => {
  8. try {
  9. const result = await cb()
  10. return result
  11. } finally {
  12. await Instance.dispose()
  13. }
  14. },
  15. })
  16. }