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

    mos-read-pkg-up

    1.0.0 • Public • Published

    mos-read-pkg-upBuild status for master

    Read the closest package.json file

    Why

    Installation

    This module is installed via npm:

    npm install mos-read-pkg-up --save

    Usage

    const readPkgUp = require('mos-read-pkg-up');
     
    readPkgUp().then(result => {
        console.log(result);
        //> { pkg:
        //     { name: 'mos-read-pkg-up',
        //       version: '1.0.2',
        //       description: 'Read the closest package.json file',
        //       license: 'MIT',
        //       repository:
        //        { type: 'git',
        //          url: 'git+ssh://git@github.com/zkochan/read-pkg-up.git' },
        //       author:
        //        { name: 'Sindre Sorhus',
        //          email: 'sindresorhus@gmail.com',
        //          url: 'sindresorhus.com' },
        //       engines: { node: '>=0.10.0' },
        //       scripts: { test: 'xo && ava', md: 'mos' },
        //       files: [ 'index.js' ],
        //       keywords:
        //        [ 'json',
        //          'read',
        //          'parse',
        //          'file',
        //          'fs',
        //          'graceful',
        //          'load',
        //          'pkg',
        //          'package',
        //          'find',
        //          'up',
        //          'find-up',
        //          'findup',
        //          'look-up',
        //          'look',
        //          'file',
        //          'search',
        //          'match',
        //          'package',
        //          'resolve',
        //          'parent',
        //          'parents',
        //          'folder',
        //          'directory',
        //          'dir',
        //          'walk',
        //          'walking',
        //          'path' ],
        //       dependencies: { 'mos-read-pkg': '^1.1.2', 'find-up': '^1.0.0' },
        //       devDependencies: { ava: '*', mos: '^0.16.0', xo: '*' },
        //       bugs: { url: 'https://github.com/zkochan/read-pkg-up/issues' },
        //       readme: 'ERROR: No README data found!',
        //       homepage: 'https://github.com/zkochan/read-pkg-up#readme',
        //       _id: 'mos-read-pkg-up@1.0.2' },
        //    path: '/home/zoltan/src/read-pkg-up/package.json' }
    });

    API

    readPkgUp([options])

    Returns a promise for the result object.

    readPkgUp.sync([options])

    Returns a result object.

    options

    cwd

    Type: string
    Default: .

    Directory to start looking for a package.json file.

    normalize

    Type: boolean
    Default: true

    Normalize the package data.

    Related

    • read-pkg - Read a package.json file
    • pkg-up - Find the closest package.json file
    • find-up - Find a file by walking up parent directories
    • pkg-conf - Get namespaced config from the closest package.json

    License

    MIT © Sindre Sorhus

    Install

    npm i mos-read-pkg-up

    DownloadsWeekly Downloads

    23

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • avatar