aprilandjan / find-lerna-packages

An utility module to find information of packages in a lerna project, no matter where the execute working directory in lerna project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

An utility module to find information of packages in a lerna project, no matter where the execute working directory in lerna project.

License:MIT License


Languages

Language:TypeScript 96.1%Language:JavaScript 3.9%