read-pkg

  • Version 7.0.0
  • Published
  • 5.79 kB
  • 4 dependencies
  • MIT license

Install

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

Overview

Read a package.json file

Index

Functions

function readPackage

readPackage: {
(options?: NormalizeOptions): Promise<NormalizedPackageJson>;
(options: Options): Promise<any>;
};
  • Returns

    The parsed JSON.

    Example 1

    import {readPackage} from 'read-pkg';
    console.log(await readPackage());
    //=> {name: 'read-pkg', …}
    console.log(await readPackage({cwd: 'some-other-directory'});
    //=> {name: 'unicorn', …}

function readPackageSync

readPackageSync: {
(options?: NormalizeOptions): NormalizedPackageJson;
(options: Options): any;
};
  • Returns

    The parsed JSON.

    Example 1

    import {readPackageSync} from 'read-pkg';
    console.log(readPackageSync());
    //=> {name: 'read-pkg', …}
    console.log(readPackageSync({cwd: 'some-other-directory'});
    //=> {name: 'unicorn', …}

Interfaces

interface NormalizeOptions

interface NormalizeOptions extends Options {}

    property normalize

    readonly normalize?: true;

      interface Options

      interface Options {}

        property cwd

        readonly cwd?: string;
        • Current working directory.

          process.cwd()

        property normalize

        readonly normalize?: boolean;
        • [Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.

          true

        Type Aliases

        type NormalizedPackageJson

        type NormalizedPackageJson = PackageJson & normalize.Package;

          type PackageJson

          type PackageJson = typeFest.PackageJson;

            Package Files (1)

            Dependencies (4)

            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.

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