PathUtils

node/pathUtils. PathUtils

A utility services to manage paths on a project. It allows for path building relatives to the project root or from where the app executable is located.

Constructor

new PathUtils(homeopt)

Source:
Tutorials:
Parameters:
Name Type Attributes Default Description
home string <optional>
''

The location of the project's home(root) directory. By default it uses process.cwd().

Members

app :string

Source:

The path to the directory where the app executable is located.

Type:

home :string

Source:

The project root path.

Type:

Methods

addLocation(name, locationPath)

Source:

Adds a new location.

Parameters:
Name Type Description
name string

The reference name.

locationPath string

The path of the location. It must be inside the path from the app is being executed.

getLocation(name) → {string}

Source:

Gets a location path by its name.

Parameters:
Name Type Description
name string

The location name.

Throws:

If there location hasn't been added.

Type
Error
Returns:
Type
string

join(…paths) → {string}

Source:

Alias to joinFrom that uses the home location by default.

Parameters:
Name Type Attributes Description
paths string <repeatable>

The rest of the path components to join.

Returns:
Type
string

joinFrom(location, …paths) → {string}

Source:

Builds a path using a location path as base.

Parameters:
Name Type Attributes Description
location string

The location name.

paths string <repeatable>

The rest of the path components to join.

Returns:
Type
string