0.0.2 • Published 10 months ago

npm-package-reader v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

npm-package-reader

Simple library for read and parse package.json files.

Install

npm i npm-package-reader

API

  • readPackage - Asynchronous function to read and parse package.json.
  • readPackageSync - Synchronous function to read and parse package.json.

Usage

readPackage

readPackage(cwd?: string): Promise<IPackageJson | false>

NOTE: This function reads the package.json file asynchronously from the specified directory (default is the current working directory).

import { readPackage } from 'npm-package-reader';

async function getPackageData() {
  const data = await readPackage(); // Reads from the current working directory
  console.log(data);
}

getPackageData();

readPackageSync

readPackageSync(cwd?: string): IPackageJson | false

NOTE: This function reads the package.json file synchronously from the specified directory (default is the current working directory).

import { readPackageSync } from 'npm-package-reader';

function getPackageDataSync() {
  const data = readPackageSync(); // Reads from the current working directory
  console.log(data);
}

getPackageDataSync();
0.0.2

10 months ago

0.0.1

10 months ago