Skip to content

Path.cwd() method

pathlib-ts > Path > cwd

Return a new path pointing to the current working directory.

Signature:

static cwd(): Promise<Path>;

Returns:

Promise<Path>

Promise resolving to a Path instance targeting the current working directory.

Mirrors the CPython API and caches the string representation for parity with the synchronous constructor.

Discovering the working directory asynchronously

import { Path } from "pathlib-ts";
const cwd = await Path.cwd();
console.log(cwd.toString());