Nascent Prototype Metaverse

    tilde-path

    3.0.0 • Public • Published

    tilde-path

    NPM version Build Status Build status Coverage Status

    Resolve a path into an absolute path, using tilde (~) if possible

    // On /Users/shinnn/project
    const tildePath = require('tilde-path');
     
    tildePath('foo'); //=> '~/project/foo'
    tildePath('foo/bar'); //=> '~/project/foo/bar'
    tildePath('../'); //=> '~'

    Installation

    Use npm.

    npm install tilde-path
    

    API

    const tildePath = require('tilde-path');

    tildePath(path)

    path: string
    Return: string

    On a non-Windows environment,

    1. Resolves a given path into an absolute path if it's relative
    2. Replaces the home directory path with ~

    On Windows, it just calls path.win32.resolve because Windows doesn't support tilde home path.

    // On POSIX
    tildePath('my/dir'); //=> '~/my/dir'
     
    // On Windows
    tildePath('my/dir'); //=> 'C:\\Users\\shinnn\\my\\dir'

    License

    ISC License © 2018 Shinnosuke Watanabe

    Install

    npm i tilde-path

    DownloadsWeekly Downloads

    599

    Version

    3.0.0

    License

    ISC

    Unpacked Size

    3.88 kB

    Total Files

    4

    Last publish

    Collaborators

    • shinnn