Skip to content

Path.existsSync() method

pathlib-ts > Path > existsSync

Checks for path existence synchronously.

Signature:

existsSync(options?: {
followSymlinks?: boolean;
}): boolean;

Parameter

Type

Description

options

{ followSymlinks?: boolean; }

(Optional) Optional follow-symlink toggle.

Returns:

boolean

true if the path exists (following symlinks by default).

Supports followSymlinks: false to test dangling links, matching CPython’s API.

Guarding a cache file synchronously

import { Path } from "pathlib-ts";
const cache = new Path("./.cache/state.json");
if (cache.existsSync()) {
console.log("warm cache detected");
}