Import
import {
readTextFile,
writeTextFile,
join,
resolve,
exists,
mkdir,
} from "veryfront/fs";
Examples
File operations
import { exists, mkdir, readTextFile, writeTextFile } from "veryfront/fs";
const content = await readTextFile("./data/config.json");
await writeTextFile("./output/result.json", JSON.stringify(data));
await mkdir("./output", { recursive: true });
Path utilities
import { join, resolve, dirname, basename, extname } from "veryfront/fs";
const filePath = join("src", "pages", "index.tsx");
const dir = dirname(filePath); // "src/pages"
Working directory
import { cwd, resolve } from "veryfront/fs";
const configPath = resolve(cwd(), "veryfront.config.ts");
Exports
Functions
| Name | Description | Source |
|---|---|---|
basename | Return the last path segment. | source |
createFileSystem | Create file system. | source |
cwd | Return the current working directory. | source |
dirname | Return the parent directory path. | source |
exists | Check whether a path exists. | source |
extname | Return the file extension for a path. | source |
join | Join path segments. | source |
mkdir | Create a directory. | source |
readDir | Read directory entries. | source |
readTextFile | Read a file as text. | source |
realPath | Resolve a path to its canonical absolute form, following symlinks. Throws if the path does not exist. Useful for containment checks where a symlink could otherwise escape an intended directory. | source |
remove | Remove a file or directory. | source |
resolve | Resolve path segments to an absolute path. | source |
writeTextFile | Write text to a file. | source |
Types
| Name | Description | Source |
|---|---|---|
FileSystem | Public API contract for file system. | source |