Luvit 2.5.6 Documentation


This module contains utilities for handling and transforming file paths. Almost all these methods perform only string transformations. The file system is not consulted to check whether paths are valid. Supports both windows and posix.

Use require('path') to use this module. The following methods are provided:


Gets the filesystems root path.


Gets the filesystems default path seperator

path.pathEquals(a, b)#

Checks if path a is equal to b


Normalize a string path, taking care of '..' and '.' parts.

When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.


Joins a splat of different strings together with the default seperator to form a valid path

path.resolve([from ...], to)#

Works backwards, joining the arguments until it resolves to an absolute path. If an absolute path is not resolved, then the current working directory is prepended


> path.resolve('/foo/bar', '/tmp/file/')

path.relative(from, to)#

Returns the relative path from 'from' to 'to' If no relative path can be solved, then 'to' is returned


Return the directory name of a path. Similar to the Unix dirname command.

path.basename(filepath, expected_ext)#

Return the last portion of a path. Similar to the Unix basename command.


Return the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string. Examples:


Checks if filepath is absolute


Checks if the path follows Microsofts universal naming convention


Drive-relative paths are unique to Windows and use the format <letter>:filepath


Returns file path with posix seperators