Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    tilde-expansionpublic

    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

    none

    install

    npm i tilde-expansion

    Downloadsweekly downloads

    321

    version

    0.0.0

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar