How to use @lerna/command - 1 common examples

To help you get started, we’ve selected a few @lerna/command 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 elastic / apm-agent-rum-js / scripts / publish-package.js View on Github external
const [, , packageName] = process.argv

if (!packageName) {
  throw new Error('Please provide the name of the package to publish')
}

function checkValidPackages(packages) {
  return packages.some(({ name }) => name === packageName)
}

/**
 * We override the Lerna prepration command which takes of
 * building the package graph for publishing packages
 */
Command.prototype.runPreparations = async function() {
  /**
   * List of packages that are present under /packages/ folder
   */
  const packages = await this.project.getPackages()

  if (!checkValidPackages(packages)) {
    const message = `
    Error: Please provide a valid package name

    Valid pacakges: ${packages.map(pkg => pkg.name).join(', ')}
    `
    console.error(message)
    process.exit(1)
  }

  const filteredPackages = packages.filter(({ name }) => name === packageName)

@lerna/command

Lerna's internal base class for commands

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis

Popular @lerna/command functions