Skip to main content
Version: v0.0.2

Function: readFileBytes()

readFileBytes(path): Promise<Uint8Array<ArrayBufferLike>>

Read a file into bytes, mapping any read failure to a value-free CLI_NO_INPUT / EXIT.NOINPUT error. The path is structural context (the user supplied it), so it may appear in the message; the file contents never do.

Parameters

path

string

The file path to read.

Returns

Promise<Uint8Array<ArrayBufferLike>>

The file bytes.

Throws

CLI_NO_INPUT (exit 66) when the file is missing, a directory, or unreadable.

Example

import { readFileBytes } from "@cosyte/cli";

await readFileBytes("/no/such/file"); // throws CliError CLI_NO_INPUT