Path.mkdir() method
pathlib-ts > Path > mkdir
Path.mkdir() method
Section titled “Path.mkdir() method”Create a directory with optional parents and existOk semantics.
Signature:
mkdir(options?: { parents?: boolean; existOk?: boolean; mode?: number; }): Promise<void>;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
options |
{ parents?: boolean; existOk?: boolean; mode?: number; } |
(Optional) POSIX-style creation options ( |
Returns:
Promise<void>
Promise that settles once the directory exists.
Remarks
Section titled “Remarks”Delegates to Node’s fs.mkdir while matching CPython defaults for parent creation and error handling.
Example
Section titled “Example”Ensuring nested directories asynchronously
import { Path } from "pathlib-ts";
const assets = new Path("./public/assets/icons");await assets.mkdir({ parents: true, existOk: true });