import { copySync } from "https://deno.land/std@0.222.1/fs/copy.ts";
Synchronously 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 { copySync } from "https://deno.land/std@0.222.1/fs/copy.ts";
copySync("./foo", "./bar");
This will copy the file or directory at ./foo
to ./bar
without
overwriting.
Overwriting files/directories
Overwriting files/directories
import { copySync } from "https://deno.land/std@0.222.1/fs/copy.ts";
copySync("./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 { copySync } from "https://deno.land/std@0.222.1/fs/copy.ts";
copySync("./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.