1.3.0 • Published 3 years ago

find-lerna-packages v1.3.0

Weekly downloads
545
License
MIT
Repository
github
Last release
3 years ago

find-lerna-packages

version version

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

1.3.0

3 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.0

5 years ago