path.relative()

path.relative(from, to) Solve the relative path from from to to. At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve, which means we see that: path.resolve(from, path.relative(from, to)) == path.resolve(to) Examples: path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb') // returns '..\\..\\impl\\bbb' path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb') // returns '

path.posix

path.posix Provide access to aforementioned path methods but always interact in a posix compatible way.

path.parse()

path.parse(pathString) Returns an object from a path string. An example on *nix: path.parse('/home/user/dir/file.txt') // returns // { // root : "/", // dir : "/home/user/dir", // base : "file.txt", // ext : ".txt", // name : "file" // } An example on Windows: path.parse('C:\\path\\dir\\index.html') // returns // { // root : "C:\\", // dir : "C:\\path\\dir", // base : "index.html", // ext : ".html", // name : "index" // }

path.normalize()

path.normalize(p) 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. Example: path.normalize('/foo/bar//baz/asdf/quux/..') // returns '/foo/bar/baz/asdf' Note: If the path string passed as argument is a zero-length string then '.' will be returned, which represents the current working directory.

path.join()

path.join([path1][, path2][, ...]) Join all arguments together and normalize the resulting path. Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. Example: path.join('/foo', 'bar', 'baz/asdf', 'quux', '..') // returns '/foo/bar/baz/asdf' path.join('foo', {}, 'bar') // throws exception TypeError: Arguments to path.join must be strings Note: If the arguments to join have zero-length strings, unlike other path module functi

path.isAbsolute()

path.isAbsolute(path) Determines whether path is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. Posix examples: path.isAbsolute('/foo/bar') // true path.isAbsolute('/baz/..') // true path.isAbsolute('qux/') // false path.isAbsolute('.') // false Windows examples: path.isAbsolute('//server') // true path.isAbsolute('C:/foo/..') // true path.isAbsolute('bar\\baz') // false path.isAbsolute('.') // false Not

path.format()

path.format(pathObject) Returns a path string from an object. This is the opposite of path.parse. If pathObject has dir and base properties, the returned string will be a concatenation of the dir property, the platform-dependent path separator, and the base property. If the dir property is not supplied, the root property will be used as the dir property. However, it will be assumed that the root property already ends with the platform-dependent path separator. In this case, the returned strin

path.extname()

path.extname(p) 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: path.extname('index.html') // returns '.html' path.extname('index.coffee.md') // returns '.md' path.extname('index.') // returns '.' path.extname('index') // returns '' path.extname('.index') // returns ''

path.dirname()

path.dirname(p) Return the directory name of a path. Similar to the Unix dirname command. Example: path.dirname('/foo/bar/baz/asdf/quux') // returns '/foo/bar/baz/asdf'

path.delimiter

path.delimiter The platform-specific path delimiter, ; or ':'. An example on *nix: console.log(process.env.PATH) // '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin' process.env.PATH.split(path.delimiter) // returns ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'] An example on Windows: console.log(process.env.PATH) // 'C:\Windows\system32;C:\Windows;C:\Program Files\node\' process.env.PATH.split(path.delimiter) // returns ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program File