Platform environment PATH delimiter.
Example of how PATH appears on Windows:
'C:\Windows\system32;C:\Windows;C:\Program Files\node\'
Example of how PATH appears on POSIX systems (Mac Unix):
'/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'
Read the PATH with Node:
console.log(process.env.PATH)
Windows = ;
POSIX = :
Adds a trailing slash from path (if doesn't exist).
path
npath.basename("/foo/bar/bob.txt") --> "bob.txt"
npath.basename("/foo/bar/bob.txt", ".txt") --> "bob"
The full path
Lops off the extension if it matches.
The last portion of a path, generally the "filename".
Normalizes slashes by converting double \ to single \ and / to \ or \ tp / based on the current platform requirements.
arg
Returns the path to the parent folder that the item resides within.
npath.dirname("/foo/bar/bob.txt") --> "/foo/bar"
npath.dirname("/foo/sally/yoyo/boob") --> "/foo/sally/yoyo"
The path to parse.
The path to the file/folder.
Yes, this includes the dot.
npath.extname("/foo/bar/bob.txt") --> ".txt"
npath.extname("/foo/sally/yoyo/boob") --> ""
The path to parse.
The extension (if exists), including the dot.
The opposite of path.parse().
Combines the elements of an object into a string.
Example:
{
root : "/",
dir : "/home/user/dir",
base : "file.txt",
ext : ".txt",
name : "file"
}
Is converted to
/home/user/dir/file.txt
The object containing some of the required keys to formulate a path.
The string representaiton of the object.
Determines if path is an absolute path.
The path to parse.
Joins path segments and resolves relativity.
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
Returns: '/foo/bar/baz/asdf'
All arguments are evaluated as paths for construction
description description
Resolves ".." and "." portions of a path.
Reduces double slashes to single (e.g. // -> / )
Forces back-slashes to forward slashes (e.g. \ -> / )
Retains trailing slash if exists.
npath.normalize("/foo/////bar") --> "/foo/bar"
npath.normalize("/foo/bar/../boob") --> "/foo/boob"
npath.normalize("./foo/") --> "/current/working/dir/foo/"
The path to parse.
Extracts basic path and file parts.
path.parse('/home/user/dir/file.txt')
// Yeilds
{
root : "/",
dir : "/home/user/dir",
base : "file.txt",
ext : ".txt",
name : "file"
}
The path to parse.
An object containing the following properties:
{
root : "/",
dir : "/home/user/dir",
base : "file.txt",
ext : ".txt",
name : "file"
}
Creates a relative path between from
adn to
.
path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')
// Returns: '../../impl/bbb'
When null, the cwd is used for this value.
When null, the cwd is used for this value.
The relative path between from
and to
Removes a trailing slash from path (if exists).
path
Generates an absolute path based on thenprovided arguments.
Path construction occurs from right < to < left
resolve("/a", "b", "c"); // yields: "/a/b/c"
If an absolute path is resolved during construction, the items to the left are ignored.
resolve("a", "/b", "c"); // yields: "/b/c" ("a" is ignored)
If an absolute path is not resolved after constructing all arguments, the CWD is inserted.
resolve("a", "b", "c"); // yields: "/current/working/dir/a/b/c"
Relative paths are automatically resolved:
resolve("/a", "../b", "c"); // yields "/a/c"
All arguments are evaluated as paths for construction.