read-pkg-up

  • Version 8.0.0
  • Published
  • 6.61 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 readPackageUpAsync

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

    Example 1

    import {readPackageUpAsync} from 'read-pkg-up';
    console.log(await readPackageUpAsync());
    // {
    // 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'
    // }

Interfaces

interface NormalizedReadResult

interface NormalizedReadResult {}

    property packageJson

    packageJson: NormalizedPackageJson;

      property path

      path: string;

        interface ReadResult

        interface ReadResult {}

          property packageJson

          packageJson: PackageJson;

            property path

            path: string;

              Type Aliases

              type NormalizeOptions

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

                type Options

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

                  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>