package.json
utils.
npm install @universal-packages/package-json
Reads the package.json
file as a JSON of the current working directory or if a package name is passed and its installed under node_modules
the package.json
is read from that package.
import { readPackageJson } from '@universal-packages/package-json'
const json = readPackageJson('jest')
console.log(json)
// > { name: 'jest', ...}
PackageJson
for a more in deep mapping of the package.json
file.
import { PackageJson } from '@universal-packages/package-json'
const packageJson = new PackageJson()
packageJson.read()
Reads the root package.json
file and all its dependencies recursively generating a new PackageJson
object for ech dependency.
Name of the package being mapped.
Version of the package being mapped.
The package.json
object of the package being mapped.
All the uniq dependencies read while reading recursively.
Collection of all dependencies read as PackageJson objects.
Collection of all devDependencies read as PackageJson objects.
Collection of all peerDependencies read as PackageJson objects.
Collection of all peerDependenciesMeta read as PackageJson objects.
Collection of all bundleDependencies read as PackageJson objects.
Collection of all optionalDependencies read as PackageJson objects.
This library is developed in TypeScript and shipped fully typed.
The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.