1.3.0 • Published 3 years ago
find-lerna-packages v1.3.0
find-lerna-packages
An utility module to help find lerna packages in lerna project programmatically, asynchronously or synchronously.
Usage
Install via yarn
:
yarn add find-lerna-package
Install via npm
:
npm install find-lerna-packages
Then in your source codes:
const findLernaPackages = require('find-lerna-packages');
// asynchronous: return a promise resolved with `LernaPackage` array
findLernaPackages(process.cwd()).then((pkgList) => {
pkgList.forEach(pkg => {
console.log(pkg.name, pkg.location);
});
});
// synchronous: return `LernaPackage` array
findLernaPackages.sync(process.cwd()).map(pkg => {
console.log(pkg.name, pkg.location);
});
// asynchronous: get `LernaPackage` directly by name
findLernaPackages.get('foo').then(pkg => {
console.log(pkg.name, pkg.location);
});
// synchronous: get `LernaPackage` directly by name
const pkg = findLernaPackages.getSync('foo');
console.log(pkg.name, pkg.location);
// synchronous: get root `LernaPackage` directly
const root = findLernaPackages.getRoot();
console.log(pkg.name, pkg.location);
About LernaPackage
LernaPackage
is actually the class describing lerna sub packages from @lerna/package
, which is used by lerna cli internally. This utility module provides a simple type definition of it for friendly usage.
You can read package properties directly, such as name
,location
, private
,rootPath
, etc.
LICENSE
MIT