Skip to content

Path.rename() method

pathlib-ts > Path > rename

Rename this path to the given target and return the new path instance.

Signature:

rename(target: PathLike): Promise<Path>;

Parameter

Type

Description

target

PathLike

Destination path or string.

Returns:

Promise<Path>

Promise resolving to a Path representing the destination.

Matches CPython semantics while returning a new Path pointing at the destination.

Renaming build artifacts asynchronously

import { Path } from "pathlib-ts";
const artifact = new Path("./dist/app.tmp");
await artifact.rename("./dist/app.js");