Folder
The Folder resource creates and manages directories in the filesystem with automatic parent directory creation and cleanup on deletion.
Minimal Example
Section titled “Minimal Example”Create a directory using the ID as the path:
import { Folder } from "alchemy/fs";
const dir = await Folder("uploads");
Custom Path
Section titled “Custom Path”Create a directory with an explicit path:
import { Folder } from "alchemy/fs";
const logs = await Folder("logs", { path: "var/log/app",});
Recursive Creation
Section titled “Recursive Creation”Create nested directories with recursive creation enabled (default):
import { Folder } from "alchemy/fs";
const nested = await Folder("nested", { path: "path/to/nested/dir", recursive: true,});
Cleanup Options
Section titled “Cleanup Options”Control folder deletion behavior:
import { Folder } from "alchemy/fs";
const temp = await Folder("temp", { path: "temp", delete: true, // Delete on destroy (default) clean: true, // Remove contents on delete});