How to use the lerna/lib/PackageUtilities.topologicallyBatchPackages 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 wix / lerna-script / lerna-script / lib / packages.js View on Github external
if (packageConfigs) {
    log.verbose('loadPackages', 'using provided packageConfigs', {
      packageConfigs: effectivePackageConfigs
    })
  } else {
    log.verbose('loadPackages', 'using default packageConfigs', {
      packageConfigs: effectivePackageConfigs
    })
  }

  const loadedPackages = PackageUtilities.getPackages({
    rootPath: repo.rootPath,
    packageConfigs: effectivePackageConfigs
  })

  const batched = PackageUtilities.topologicallyBatchPackages(loadedPackages)
  return _.flatten(batched)
}
github wix / lerna-script / lerna-script / lib / iterators.js View on Github external
return taskFn => {
    const filteredLernaPackages = filterBuilt(lernaPackages, log, build);
    const promisifiedTaskFn = Promise.method(taskFn);
    const forEachTracker = log.newGroup('batched', lernaPackages.length);
    npmlog.enableProgress();

    const batchedPackages = PackageUtilities.topologicallyBatchPackages(filteredLernaPackages);
    const lernaTaskFn = lernaPackage => done => {
      const promiseTracker = forEachTracker.newItem(lernaPackage.name);
      promiseTracker.pause();
      promisifiedTaskFn(lernaPackage, promiseTracker)
        .then(() => build && markPackageBuilt(lernaPackage, {log: forEachTracker})(build))
        .then(done)
        .catch(done)
        .finally(() => {
          promiseTracker.resume();
          promiseTracker.completeWork(1);
        })
    };

    return new Promise((resolve, reject) => {
      PackageUtilities.runParallelBatches(batchedPackages, lernaTaskFn, 4, err => err ? reject(err) : resolve());
    });