fs
The fs module provides an interface for reading and writing to the filesystem.
Filesystem is sandboxed
All filesystem operations are done in a sandboxed directory. See Sandbox.
Summary
Methods
| Method | Signature | Description |
|---|---|---|
read | (path: string) -> string | Reads the contents of a file as a string. |
write | (path: string, content: string) -> () | Writes a string to a file. |
exists | (path: string) -> boolean | Returns whether a file or directory exists. |
remove | (path: string) -> () | Deletes a file or directory. |
list | (path: string) -> {string} | Returns the entries in a directory. |
mkdir | (path: string, recursive: boolean?) -> () | Creates a directory. |
move | (from: string, to: string) -> () | Moves or renames a file or directory. |
copy | (from: string, to: string) -> () | Copies a file to a new location. |
metadata | (path: string) -> Metadata | Returns metadata about a file or directory. |
walk | (path: string, options: WalkOptions?) -> () -> string? | Recursively iterates all files under a directory. |
watch | (path: string) -> Watcher | Returns a push-based watcher with a Signal for change events. |