Skip to content

Path.expandUserSync() method

pathlib-ts > Path > expandUserSync

Expand leading ~ markers synchronously.

Signature:

expandUserSync(): Path;

Returns:

Path

A Path with user-home prefixes expanded.

The Error class When the home directory cannot be determined.

Mirrors Path.expandUser() but executes synchronously.

Resolving a home-relative config synchronously

import { Path } from "pathlib-ts";
const config = new Path("~/.config/app/settings.json");
console.log(config.expandUserSync().toString());