bundledMode.ts
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 /** 13 * Detects if running as a Bun-compiled standalone executable. 14 * This checks for embedded files which are present in compiled binaries. 15 */ 16 export function isInBundledMode(): boolean { 17 return ( 18 typeof Bun !== 'undefined' && 19 Array.isArray(Bun.embeddedFiles) && 20 Bun.embeddedFiles.length > 0 21 ) 22 }