# replace-homedir

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

Latest version **2.0.0** (published 2022-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install replace-homedir
pnpm add replace-homedir
yarn add replace-homedir
bun add replace-homedir
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-01-31 |
| First published | 2017-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 10.13.0 |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Gulp Team |
| Maintainers | yocontra, phated |
| Keywords | path, homedir, tilde, replace, subsitute, user home, tilde |

## Links

- npm: https://www.npmjs.com/package/replace-homedir
- Repository: https://github.com/gulpjs/replace-homedir
- Homepage: https://github.com/gulpjs/replace-homedir#readme
- Issues: https://github.com/gulpjs/replace-homedir/issues
- npm.io page: https://npm.io/package/replace-homedir

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2022-01-31
- 1.0.0 — 2017-12-07
- 0.1.0 — 2017-12-06

## README

<p align="center">
  <a href="https://gulpjs.com">
    <img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
  </a>
</p>

# replace-homedir

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]

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

## Usage

```js
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

<!-- prettier-ignore-start -->
[downloads-image]: https://img.shields.io/npm/dm/replace-homedir.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/replace-homedir
[npm-image]: https://img.shields.io/npm/v/replace-homedir.svg?style=flat-square

[ci-url]: https://github.com/gulpjs/replace-homedir/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/replace-homedir/dev?style=flat-square

[coveralls-url]: https://coveralls.io/r/gulpjs/replace-homedir
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/replace-homedir/master.svgstyle=flat-square
<!-- prettier-ignore-end -->

---
_Source: https://npm.io/package/replace-homedir · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
