Socket
Socket
Sign inDemoInstall

replace-homedir

Package Overview
Dependencies
8
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    replace-homedir

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


Version published
Maintainers
1
Install size
64.8 kB
Created

Changelog

Source

2.0.0 (2022-01-31)

⚠ BREAKING CHANGES

  • Normalize repository, dropping node <10.13 support (#2)

Features

  • Remove all dependencies and only rely on node APIs (0a27bc1)

Miscellaneous Chores

  • Normalize repository, dropping node <10.13 support (#2) (0a27bc1)

Readme

Source

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

Keywords

FAQs

Last updated on 07 Dec 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc