Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)