mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
refactor: safely access Bun.main with optional chaining
This commit is contained in:
@@ -6,7 +6,8 @@ import packageJson from '../package.json';
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
/** Bun embeds compiled code in a virtual filesystem: /$bunfs/ (Linux/macOS) or /~BUN/ (Windows) */
|
||||
const isCompiled = Bun.main.includes('$bunfs') || Bun.main.includes('/~BUN/');
|
||||
const bunMain = globalThis.Bun?.main ?? '';
|
||||
const isCompiled = bunMain.includes('$bunfs') || bunMain.includes('/~BUN/');
|
||||
|
||||
export function projectPath(): string {
|
||||
return resolve(__dirname, '..');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/** Bun embeds compiled code in a virtual filesystem: /$bunfs/ (Linux/macOS) or /~BUN/ (Windows) */
|
||||
export function isBunCompiled(): boolean {
|
||||
return Bun.main.includes('$bunfs') || Bun.main.includes('/~BUN/');
|
||||
const bunMain = globalThis.Bun?.main ?? '';
|
||||
return bunMain.includes('$bunfs') || bunMain.includes('/~BUN/');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user