Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tilde-expansion

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tilde-expansion

Expand a ~ character to a users home directory like bash

  • 0.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
600
increased by12.78%
Maintainers
1
Weekly downloads
 
Created
Source

tilde-expansion

Expand a ~ character to a users home directory like bash

Examples

Given

var tilde = require('tilde-expansion');

You can do basic expansion

tilde('~root', function(s) {
  console.log(s);
});

yields

/root

or even simpler

tilde('~/', function(s) {
  console.log(s);
});

yields

/home/dave/

and get fancy with the PWD

tilde('~+', function(s) {
  console.log(s);
});

yields

/home/dave/dev

Notes

  • Any unrecognized expansions will result in the string being unchanged
  • The node etc-passwd module is used to determine the home directory of a user
  • If the user is not found on the system, the expansion will remain unaltered
  • The string must be unquoted for any expansion to take place (see bash(1))

Usage

var tilde = require('tilde-expansion');

Installation

npm install tilde-expansion

Tests

npm test

License

MIT License

Keywords

FAQs

Package last updated on 18 Sep 2012

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc