/** * The filesystem interface. * * The filesystem interface is a strict subset of `node:fs/promises` * that is cross platform compatible (browser, node). * * Node API reference https://nodejs.org/api/fs.html#fspromisesaccesspath-mode */ export type NodeishFilesystem = { writeFile: (path: string, data: string | Uint8Array, options?: { mode: number }) => Promise readFile: (path: string, options?: { encoding: "utf-8" | "binary" }) => Promise readdir: (path: string) => Promise /** * https://nodejs.org/api/fs.html#fspromisesmkdirpath-options * * Upon success, fulfills with undefined if recursive is false, or the first directory path created if recursive is true. */ mkdir: (path: string, options?: { recursive: boolean }) => Promise rm: (path: string, options?: { recursive: boolean }) => Promise rmdir: (path: string) => Promise symlink: (target: string, path: string) => Promise unlink: (path: string) => Promise readlink: (path: string) => Promise stat: (path: string) => Promise lstat: (path: string) => Promise } export type FileData = string | Uint8Array export type NodeishStats = { ctimeMs: number mtimeMs: number dev: number ino: number mode: number uid: number gid: number size: number isFile: () => boolean isDirectory: () => boolean isSymbolicLink: () => boolean symlinkTarget?: string }