tilde-path
Resolve a path into an absolute path, using tilde (~
) if possible
// On /Users/shinnn/projectconst tildePath = ; ; //=> '~/project/foo'; //=> '~/project/foo/bar'; //=> '~'
Installation
npm install tilde-path
API
const tildePath = ;
tildePath(path)
path: string
Return: string
On a non-Windows environment,
- Resolves a given path into an absolute path if it's relative
- Replaces the home directory path with
~
On Windows, it just calls path.win32.resolve
because Windows doesn't support tilde home path.
// On POSIX; //=> '~/my/dir' // On Windows; //=> 'C:\\Users\\shinnn\\my\\dir'
License
ISC License © 2018 Shinnosuke Watanabe