interface BunModules

The built-ins buildBunHost needs, injectable so every wrapper is unit-testable without real file-system access. Shapes match node:fs (sync), node:os, and node:process, all of which Bun implements.

Properties

fs: { createReadStream?: (
path: string,
options?: { start?: number; end?: number; }
) => NodeJS.ReadableStream | null
; readFileSync(path: string): Uint8Array; realpathSync(path: string): string; writeFileSync(
path: string,
): void; statSync(path: string): { size: number; mtime: Date; isFile(): boolean; isDirectory(): boolean; }; readdirSync(path: string): string[]; mkdirSync(
path: string,
options?: { recursive?: boolean; }
): string | undefined; rmSync(
path: string,
options?: { recursive?: boolean; }
): void; }

Synchronous file-system operations (compatible with node:fs).

proc: { version: string; versions: Record<string, string | undefined>; env: Record<string, string | undefined>; exit: (code?: number) => never; on: (
event: RuntimeSignal,
listener: () => void
) => void
; }

Process object (version, env, exit, signal listening).

hostname: () => string

Hostname function (from node:os).

bunGlobal: { version?: string; } | undefined

The Bun global when running on Bun, undefined elsewhere — read only for its version string. Required (rather than optional) so callers and tests state it explicitly and every version-resolution arm stays reachable.

Usage

import { type BunModules } from "runtime/src/index.ts";