Have ideas to improve npm?Join in the discussion! »

    relative-package

    1.0.0 • Public • Published

    relative-package Build Status NPM version

    Find the package.json (or another) relative to a given path

    Getting Started

    Install the module with: npm install relative-package

    Usage

    Find package.json:

    var relativePackage = require('relative-package');
     
    console.log('package.json relative to where relativePackage() is called:\n  %s',
      relativePackage())
     
    console.log('package.json relative a given path:\n  %s',
      relativePackage('./test/relative-package.test.js'))
     
    console.log('package.json relative to a given absolute path:\n  %s',
      relativePackage(__dirname + '/readme.md'))
     
    console.log('package.json relative to a given package:\n  %s',
      relativePackage('mocha'))
     
    console.log('package.json relative to a given package:\n  %s',
      relativePackage('mocha'))

    Find any other file:

    var relativePackage = require('relative-package');
     
    console.log('.gitignore relative to where relativePackage() is called:\n  %s',
      relativePackage(null, '.gitignore'))
     
    console.log('Readme.md of a given package:\n  %s',
      relativePackage('mocha', 'Readme.md'))

    (see demo.js)

    Install

    npm i relative-package

    DownloadsWeekly Downloads

    44

    Version

    1.0.0

    License

    none

    Last publish

    Collaborators

    • avatar