陈鹏铭 25c6cf8178 苏南产业园 管理端 第一次提交 1 年之前
..
LICENSE 25c6cf8178 苏南产业园 管理端 第一次提交 1 年之前
README.md 25c6cf8178 苏南产业园 管理端 第一次提交 1 年之前
index.js 25c6cf8178 苏南产业园 管理端 第一次提交 1 年之前
package.json 25c6cf8178 苏南产业园 管理端 第一次提交 1 年之前

README.md

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