Skip to content

Path.copySync() method

pathlib-ts > Path > copySync

Recursively copy the file or directory tree to the destination synchronously.

Signature:

copySync(target: PathLike, options?: {
preserveMetadata?: boolean;
followSymlinks?: boolean;
}): Path;

Parameter

Type

Description

target

PathLike

Destination path or string.

options

{ preserveMetadata?: boolean; followSymlinks?: boolean; }

(Optional) Behaviour flags for metadata preservation and symlink handling.

Returns:

Path

The destination Path.

Mirrors Path.copy() but executes synchronously.

Duplicating a directory tree synchronously

import { Path } from "pathlib-ts";
const source = new Path("./templates");
source.copySync("./.cache/templates");