bootstrap.ts 532 B

12345678910111213141516171819
  1. import { Format } from "../format"
  2. import { LSP } from "../lsp"
  3. import { Plugin } from "../plugin"
  4. import { Instance } from "../project/instance"
  5. import { Share } from "../share/share"
  6. import { Snapshot } from "../snapshot"
  7. export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
  8. return Instance.provide(directory, async () => {
  9. await Plugin.init()
  10. Share.init()
  11. Format.init()
  12. LSP.init()
  13. Snapshot.init()
  14. const result = await cb()
  15. await Instance.dispose()
  16. return result
  17. })
  18. }