Filesystem
Reference for FileSystemTree, FileSystemAPI, file metadata, and export options.
Relative filesystem paths resolve from startpod.workdir. Absolute paths address the virtual filesystem directly.
File tree shape
type FileSystemTree = {
[name: string]:
| { file: { contents: string | Uint8Array } }
| { file: { symlink: string } }
| { directory: FileSystemTree }
}Methods
| Method | Description |
|---|---|
readFile(path) | Return a Uint8Array. |
readFile(path, 'utf8') | Return a string. |
writeFile(path, data, options?) | Create or replace a file and create missing parent directories. |
readdir(path, options?) | List names or Dirent-like values. |
mkdir(path, { recursive? }) | Create a directory. |
rm(path, { force?, recursive? }) | Remove a file or directory. |
rename(oldPath, newPath) | Move a path. |
watch(path, options?, listener?) | Watch changes and return { close() }. |
stat(path) | Read metadata and follow the final symlink. |
lstat(path) | Read metadata without following the final symlink. |
Each file is limited to 1 MiB. Writes that exceed the limit fail with ERR_SP_FS_FILE_TOO_LARGE instead of truncating data.
File metadata
stat() and lstat() return:
interface FileStats {
size: number
mtimeMs: number
mode: number
revision: number
isFile(): boolean
isDirectory(): boolean
isSymbolicLink(): boolean
}Permission bits are metadata; Startpod does not enforce operating-system permissions.
Export options
export() accepts format, includeNodeModules, includes, excludes, size limits, and rejectSymlinks. The default format is json, and node_modules is excluded by default.