Skip to content

About

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

Resources

Security policy

Stars

4 stars

Watchers

2 watching

Forks

Repository files navigation

replace-homedir

NPM version Downloads Build Status Coveralls Status

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.

Strict No LLM / No AI Policy

No LLMs for issues.

No LLMs for patches / pull requests.

No LLMs for comments on the bug tracker, including translation.

English is encouraged, but not required. You are welcome to post in your native language and rely on others to have their own translation tools of choice to interpret your words.

License

MIT

About

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

Resources

Security policy

Stars

4 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages