Path.copy() method
pathlib-ts > Path > copy
Path.copy() method
Section titled “Path.copy() method”Recursively copy this file or directory tree to the destination.
Signature:
copy(target: PathLike, options?: { preserveMetadata?: boolean; followSymlinks?: boolean; }): Promise<Path>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
target |
Destination path or string. | |
|
options |
{ preserveMetadata?: boolean; followSymlinks?: boolean; } |
(Optional) Behaviour flags for metadata preservation and symlink handling. |
Returns:
Promise<Path>
Promise resolving to the destination Path.
Remarks
Section titled “Remarks”Uses Node’s fs.cp to match CPython’s recursive behavior while exposing options for metadata and symlink handling.
Example
Section titled “Example”Publishing build output asynchronously
import { Path } from "pathlib-ts";
const build = new Path("./build");const publicDir = new Path("./public");await build.copy(publicDir, { preserveMetadata: true });