@particle/untildify
v3.0.2
Published
Expand the `~` shortcut at the start of a path into the current user's $HOME directory
Downloads
135
Maintainers
Keywords
Readme
@particle/untildify
Expand the ~
shortcut at the start of a path into the current user's $HOME directory
Installation
npm install @particle/untildify --save
API
@particle/untildify
module.exports(pathStr) ⇒ string ⏏
Expand ~
at the start of a path to an absolute path to the user's $HOME directory
Kind: Exported function
Returns: string - An absolute path to a location within the user's $HOME directory or the original path if ~
character is not found
| Param | Type | Description | | --- | --- | --- | | pathStr | string | Path string to operate on |
Example
const pathToBashRc = untildify('~/.bashrc');
console.log(pathToBashRc); // -> '/Users/me/.bashrc'
NOTE: Unfortunately, docs have a nasty habit of falling out of date. When in doubt, check usage in tests