How to use the lerna.getPackages function in lerna

To help you get started, we’ve selected a few lerna examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github percy / react-percy / scripts / setup-integration-tests.js View on Github external
/* eslint-disable no-console */

const chalk = require('chalk');
const fs = require('fs-extra');
const lerna = require('lerna');
const npm = require('./npm');
const pack = require('./pack');
const path = require('path');
const Repository = require('lerna/lib/Repository');

const integrationTestsDir = path.join(__dirname, '..', 'integration-tests');

const outputDir = path.join(integrationTestsDir, 'packages');
fs.mkdirsSync(outputDir);

const packages = lerna.getPackages(new Repository());
const packageLookup = packages.reduce((result, pkg) => {
  result[pkg.name] = pkg;
  return result;
}, {});

const packageTgz = {};
packages.forEach(pkg => {
  console.log(`Packing ${pkg.name}...`);
  const tgz = pack(pkg.location, pkg, outputDir);
  packageTgz[pkg.name] = tgz;
});

const installed = new Set();
const install = pkg => {
  if (installed.has(pkg.name)) {
    return;