Skip to content

Path.exists() method

pathlib-ts > Path > exists

Resolves to true when the path exists.

Signature:

exists(options?: {
followSymlinks?: boolean;
}): Promise<boolean>;

Parameter

Type

Description

options

{ followSymlinks?: boolean; }

(Optional) Optional follow-symlink toggle.

Returns:

Promise<boolean>

A promise resolving to a boolean indicating existence.

Follows symlinks by default; pass followSymlinks: false to check whether symlink exists.

Skipping optional config during startup

import { Path } from "pathlib-ts";
const localConfig = new Path("./config.local.json");
if (await localConfig.exists()) {
console.log("loading overrides");
}