Skip to content

Path.replaceSync() method

pathlib-ts > Path > replaceSync

Replace the file or directory synchronously, overwriting the destination.

Signature:

replaceSync(target: PathLike): Path;

Parameter

Type

Description

target

PathLike

Destination path or string.

Returns:

Path

A Path representing the destination.

Mirrors Path.replace() but executes synchronously.

Overwriting a manifest synchronously

import { Path } from "pathlib-ts";
const manifest = new Path("./dist/manifest.json.new");
manifest.replaceSync("./dist/manifest.json");