Read dependencies of a package.json file.
Install
npm install read-packages
Usage
const readPackages = require('read-packages');
(async()=>{
console.log(await readPackages());
//=> {dependencies: {foo: '^1.0.0',..}, devDependencies: {bar: '^2.0.0',...}}
console.log(await readPackages({dir: './some/other/directory'}));
//=> {dependencies: {...}, devDependencies: {...}}
console.log(await readPackages({removePrefix: true}));
//=> {dependencies: {foo: '1.0.0',..}, devDependencies: {bar: '2.0.0',...}}
console.log(await readPackages({removePrefix: true, flattenPackages: true}));
//=> {foo: '1.0.0',bar: '2.0.0',...}
})();
Usage without async
The module has a sync
property to use the lib without async. All the other options works just the same.
const readPackages = require('read-packages');
console.log(readPackages.
…