path

This module provides path manipulation related functions.

Functions

path.basename(p)

Returns the last component from the pathname in path, deleting any trailing / characters.

path.basename('foo/bar/baz.js');
= baz.js

See also

basename(3).

path.dirname(p)

The converse function of path.basename(). Returns the parent directory of the pathname in path.

path.dirname('foo/bar/baz.js');
= foo/bar

See also

dirname(3).

path.join(...)

Joins the given list of partial paths into a single one using / as the separator.

path.join('foo', 'bar', 'baz');
= foo/bar/baz
path.normalize(p)

Normalize the given path by performing tilde expansion and then applying realpath(3). In case of error it returns the given path unchanged.

path.normalize('~/src/sjs');
= /Users/saghul/src/sjs