πŸ“„ File detail

utils/bundledMode.ts

🧩 .tsπŸ“ 23 linesπŸ’Ύ 618 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œutils/”, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, …). On the API surface it exposes isRunningWithBun and isInBundledMode β€” mainly functions, hooks, or classes. What the file header says: Detects if the current runtime is Bun. Returns true when: - Running a JS file via the `bun` command - Running a Bun-compiled standalone executable.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

Detects if the current runtime is Bun. Returns true when: - Running a JS file via the `bun` command - Running a Bun-compiled standalone executable

πŸ“€ Exports (heuristic)

  • isRunningWithBun
  • isInBundledMode

πŸ–₯️ Source preview

/**
 * Detects if the current runtime is Bun.
 * Returns true when:
 * - Running a JS file via the `bun` command
 * - Running a Bun-compiled standalone executable
 */
export function isRunningWithBun(): boolean {
  // https://bun.com/guides/util/detect-bun
  return process.versions.bun !== undefined
}

/**
 * Detects if running as a Bun-compiled standalone executable.
 * This checks for embedded files which are present in compiled binaries.
 */
export function isInBundledMode(): boolean {
  return (
    typeof Bun !== 'undefined' &&
    Array.isArray(Bun.embeddedFiles) &&
    Bun.embeddedFiles.length > 0
  )
}