replace-homedir
Replace user home in a string with another string. Useful for tildifying a path.
Last updated 3 years ago by phated .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install replace-homedir 
SYNC missed versions from official npm registry.

replace-homedir

NPM version Downloads Build Status AppVeyor Build Status Coveralls Status Gitter chat

Replace user home in a string with another string. Useful for tildifying a path.

Usage

var replaceHomedir = require('replace-homedir');

var shortPath = replaceHomedir('/Users/phated/myProject', '~');
// shortPath === '~/myProject'

API

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.

License

MIT

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

2 Versions

  • 1.0.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Maintainers (2)
Downloads
Today 1,931
This Week 3,809
This Month 27,469
Last Day 1,878
Last Week 11,145
Last Month 52,647
Dependencies (3)
Dev Dependencies (8)

Copyright 2014 - 2016 © taobao.org |