Skip to content
GitHubXDiscord

CopyFile

The CopyFile resource lets you copy files from one location to another in the filesystem.

Copy a file to a new location:

import { CopyFile } from "alchemy/fs";
const copiedFile = await CopyFile("config-copy", {
src: "config.json",
dest: "backup/config.json",
});

Copy a file only if the destination doesn’t already exist:

import { CopyFile } from "alchemy/fs";
const safeCopy = await CopyFile("safe-copy", {
src: "data.json",
dest: "backup/data.json",
overwrite: false,
});