import { copy } from "https://deno.land/std@0.224.0/fs/mod.ts";
Asynchronously copy a file or directory. The directory can have contents.
Like cp -r
.
If src
is a directory it will copy everything inside of this directory,
not the entire directory itself. If src
is a file, dest
cannot be a
directory.
Requires the --allow-read
and --allow-write
flag.
Examples
Basic usage
Basic usage
import { copy } from "https://deno.land/std@0.224.0/fs/copy.ts";
await copy("./foo", "./bar");
This will copy the file or directory at ./foo
to ./bar
without
overwriting.
Overwriting files/directories
Overwriting files/directories
import { copy } from "https://deno.land/std@0.224.0/fs/copy.ts";
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
Preserving timestamps
import { copy } from "https://deno.land/std@0.224.0/fs/copy.ts";
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
The source file/directory path as a string or URL.
The destination file/directory path as a string or URL.
Options for copying.