read-pkg-up

  • Version 11.0.0
  • Published
  • 6.23 kB
  • 3 dependencies
  • MIT license

Install

npm i read-pkg-up
yarn add read-pkg-up
pnpm add read-pkg-up

Overview

Read the closest package.json file

Index

Functions

function readPackageUp

readPackageUp: {
(options?: NormalizeOptions): Promise<NormalizedReadResult | undefined>;
(options: any): Promise<ReadResult>;
};
  • Read the closest package.json file.

    Example 1

    import {readPackageUp} from 'read-pkg-up';
    console.log(await readPackageUp());
    // {
    // packageJson: {
    // name: 'awesome-package',
    // version: '1.0.0',
    // …
    // },
    // path: '/Users/sindresorhus/dev/awesome-package/package.json'
    // }

function readPackageUpSync

readPackageUpSync: {
(options?: NormalizeOptions): NormalizedReadResult | undefined;
(options: any): ReadResult;
};
  • Synchronously read the closest package.json file.

    Example 1

    import {readPackageUpSync} from 'read-pkg-up';
    console.log(readPackageUpSync());
    // {
    // packageJson: {
    // name: 'awesome-package',
    // version: '1.0.0',
    // …
    // },
    // path: '/Users/sindresorhus/dev/awesome-package/package.json'
    // }

Type Aliases

type NormalizedReadResult

type NormalizedReadResult = {
packageJson: NormalizedPackageJson;
path: string;
};

    type NormalizeOptions

    type NormalizeOptions = {
    /**
    The directory to start looking for a package.json file.
    @default process.cwd()
    */
    cwd?: URL | string;
    } & Except<ReadPackageNormalizeOptions, 'cwd'>;

      type Options

      type Options = {
      /**
      The directory to start looking for a package.json file.
      @default process.cwd()
      */
      cwd?: URL | string;
      } & Except<ReadPackageOptions, 'cwd'>;

        type ReadResult

        type ReadResult = {
        packageJson: PackageJson;
        path: string;
        };

          Package Files (1)

          Dependencies (3)

          Dev Dependencies (3)

          Peer Dependencies (0)

          No peer dependencies.

          Badge

          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/read-pkg-up.

          • Markdown
            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/read-pkg-up)
          • HTML
            <a href="https://www.jsdocs.io/package/read-pkg-up"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>