Last active
March 24, 2019 02:30
-
-
Save alisonailea/1e50939fcb15f3c4af0c5d5738883561 to your computer and use it in GitHub Desktop.
Check publish output of a package in the monorepo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add "check": "node ./scripts/checkPublishedPackage" to the "scripts" in your package.json | |
const { exec } = require('child_process'); | |
const chalk = require('chalk'); | |
const packageName = process.argv[2]; | |
if (!packageName) { | |
console.error(chalk.red.bold('You must provide a valid package name')); | |
console.log(chalk.grey('Example:'), '`npm run check core-package`'); | |
} | |
// assumes a structure of <root>/packages/[package-name] | |
// replace console.log with the logger of your choice. (I prefer Winston) | |
exec(`cd packages/${packageName} && npm pack --dry-run && cd -`, (error, stdout, stderr) => { | |
if (error) { | |
console.error(`exec error: ${error}`); | |
return; | |
} | |
console.log(`stdout: ${stdout}`); | |
console.log(`stderr: ${stderr}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment