Atom

path.relative()

Expresses a target relative to a base directory.

Signature

path.relative(target[, base[, style]])

Parameters

Text target, optional text base default '.', and optional style.

Returns

Relative string or absolute target when roots differ.

Behavior

Windows path comparison is ASCII case-insensitive.

Errors

Path or style error, or inability to resolve the working directory.

Example

Atom
use path
assert(path.relative('/work/lib/a', '/work', 'unix') == 'lib/a')