root 3bf41bf355 update | há 1 ano atrás | |
---|---|---|
.. | ||
LICENSE | há 1 ano atrás | |
README.md | há 1 ano atrás | |
index.js | há 1 ano atrás | |
package.json | há 1 ano atrás |
Replace user home in a string with another string. Useful for tildifying a path.
var replaceHomedir = require('replace-homedir');
var shortPath = replaceHomedir('/Users/phated/myProject', '~');
// shortPath === '~/myProject'
replaceHomedir(path, replacement)
Takes a string path
as the first argument and a string or function replacement
as the second argument. If the path
is absolute and begins with the User's homedir, the homedir portion of the path is replaced with replacement
using String#replace.
If path
is not a string, the function will throw.
MIT