What is @pnpm/read-project-manifest?
@pnpm/read-project-manifest is a utility package that allows you to read and parse the manifest files (like package.json) of a project. This can be useful for various tasks such as dependency management, project configuration analysis, and more.
What are @pnpm/read-project-manifest's main functionalities?
Read package.json
This feature allows you to read the package.json file of the current project directory. The function returns the parsed manifest object and the file name.
const { readProjectManifest } = require('@pnpm/read-project-manifest');
async function readManifest() {
const { manifest, fileName } = await readProjectManifest(process.cwd());
console.log(manifest);
console.log(`Manifest file read from: ${fileName}`);
}
readManifest();
Read specific manifest file
This feature allows you to read a specific manifest file by providing its path. The function returns the parsed manifest object.
const { readProjectManifestOnly } = require('@pnpm/read-project-manifest');
async function readSpecificManifest(filePath) {
const manifest = await readProjectManifestOnly(filePath);
console.log(manifest);
}
readSpecificManifest('./path/to/package.json');
Other packages similar to @pnpm/read-project-manifest
read-pkg
The read-pkg package is a utility for reading and parsing package.json files. It offers similar functionality to @pnpm/read-project-manifest but is more focused on simplicity and ease of use. It does not provide as many options for reading different types of manifest files.
pkg-up
The pkg-up package finds the closest package.json file by traversing up from the specified directory. While it does not directly read the manifest file, it helps locate the file, which can then be read using other utilities like read-pkg.
find-up
The find-up package is a general utility for finding a file or directory by walking up parent directories. It can be used to locate a package.json file, which can then be read using other packages. It is more versatile but less specialized than @pnpm/read-project-manifest.
@pnpm/read-project-manifest
Read a project manifest (called package.json in most cases)
Installation
pnpm add @pnpm/read-project-manifest
Usage
import { readProjectManifest } from '@pnpm/read-project-manifest'
const { manifest, fileName } = await readProjectManifest(process.cwd())
License
MIT