interface NodeHost

Minimal interface covering the Node-specific operations used by this adapter. Inject this interface to test the adapter without real Node.js.

Properties

Node.js version string (e.g. "v18.19.0").

hostname: string

Host name string.

env: Record<string, string | undefined>

Environment variable map.

exit: (code?: number) => never

Exit the process.

onSignal: (
signal: RuntimeSignal,
handler: () => void
) => void

Registers a process-termination signal listener.

readFile: (path: string) => Promise<Uint8Array>

Read file as bytes.

realPath: (path: string) => Promise<string>

Resolve a path to its canonical absolute form, following symlinks.

writeFile: (
path: string,
) => Promise<void>

Write bytes to a file.

stat: (path: string) => Promise<NodeFsInfo>

Get file/directory info.

readdir: (path: string) => Promise<readonly string[]>

List directory entries.

mkdir: (
path: string,
options?: { recursive?: boolean; }
) => Promise<void>

Create a directory.

rm: (
path: string,
options?: { recursive?: boolean; }
) => Promise<void>

Remove a file or directory.

optional
createReadStream: (
path: string,
options?: { start?: number; end?: number; }
) => NodeJS.ReadableStream | null

Create a read stream for a file. Returns null if the file cannot be opened.

Usage

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