Skip to main content
Home
Works with
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score76%
Published10 months ago (0.0.9)
function copy
copy(
src: string | URL,
dest: string | URL,
options?: CopyOptions,
): Promise<void>

Asynchronously copy a file or directory (along with its contents), like cp -r.

Both src and dest must both be a file or directory.

Requires --allow-read and --allow-write permissions.

Examples

Basic usage

import { copy } from "@std/fs/copy";

await copy("./foo", "./bar");

This will copy the file or directory at ./foo to ./bar without overwriting.

Overwriting files/directories

import { copy } from "@std/fs/copy";

await copy("./foo", "./bar", { overwrite: true });

This will copy the file or directory at ./foo to ./bar and overwrite any existing files or directories.

Preserving timestamps

import { copy } from "@std/fs/copy";

await copy("./foo", "./bar", { preserveTimestamps: true });

This will copy the file or directory at ./foo to ./bar and set the last modification and access times to the ones of the original source files.

Parameters

src: string | URL

The source file/directory path as a string or URL.

dest: string | URL

The destination file/directory path as a string or URL.

optional
options: CopyOptions

Options for copying.

Return Type

Promise<void>

A promise that resolves once the copy operation completes.

See

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@sigmasd/fs-with-x-runtime-walk

Import symbol

import { copy } from "@sigmasd/fs-with-x-runtime-walk/copy";
or

Import directly with a jsr specifier

import { copy } from "jsr:@sigmasd/fs-with-x-runtime-walk/copy";

Add Package

pnpm i jsr:@sigmasd/fs-with-x-runtime-walk
or (using pnpm 10.8 or older)
pnpm dlx jsr add @sigmasd/fs-with-x-runtime-walk

Import symbol

import { copy } from "@sigmasd/fs-with-x-runtime-walk/copy";

Add Package

yarn add jsr:@sigmasd/fs-with-x-runtime-walk
or (using Yarn 4.8 or older)
yarn dlx jsr add @sigmasd/fs-with-x-runtime-walk

Import symbol

import { copy } from "@sigmasd/fs-with-x-runtime-walk/copy";

Add Package

vlt install jsr:@sigmasd/fs-with-x-runtime-walk

Import symbol

import { copy } from "@sigmasd/fs-with-x-runtime-walk/copy";

Add Package

npx jsr add @sigmasd/fs-with-x-runtime-walk

Import symbol

import { copy } from "@sigmasd/fs-with-x-runtime-walk/copy";

Add Package

bunx jsr add @sigmasd/fs-with-x-runtime-walk

Import symbol

import { copy } from "@sigmasd/fs-with-x-runtime-walk/copy";