bundledMode.ts 618 B

12345678910111213141516171819202122
  1. /**
  2. * Detects if the current runtime is Bun.
  3. * Returns true when:
  4. * - Running a JS file via the `bun` command
  5. * - Running a Bun-compiled standalone executable
  6. */
  7. export function isRunningWithBun(): boolean {
  8. // https://bun.com/guides/util/detect-bun
  9. return process.versions.bun !== undefined
  10. }
  11. /**
  12. * Detects if running as a Bun-compiled standalone executable.
  13. * This checks for embedded files which are present in compiled binaries.
  14. */
  15. export function isInBundledMode(): boolean {
  16. return (
  17. typeof Bun !== 'undefined' &&
  18. Array.isArray(Bun.embeddedFiles) &&
  19. Bun.embeddedFiles.length > 0
  20. )
  21. }