util.join
v0.0.27
Published
Joins and normalizes a file path to a unix path.
Downloads
665
Readme
util.join
Joins and normalizes a file path into a unix path.
Using the node path.join()
on Windows results in a backslash path separator. Using it on OSX or Linux uses a forward slash. This function is a wrapper that will perform the node join and then normalize all path separators using the forward slash. e.g. the path:
C:\blah\blah\blah
will become:
C:/blah/blah/blah
OSX/Linux paths will work the same. This function will also detect the "home" path leader (~/
, ~\
, or ~
) and expand it.
Installation
This module uses yarn to manage dependencies and run scripts for development.
To install as an application dependency:
$ yarn add --dev util.join
To build the app and run all tests:
$ yarn run all
Usage
const join = require('util.join');
let s = join('C:\\', 'blah', 'blah', 'blah');
console.log(s);
// prints the path 'C:/blah/blah/blah'