Skip to content

Instantly share code, notes, and snippets.

@alisonailea
Last active March 24, 2019 02:30
Show Gist options
  • Save alisonailea/1e50939fcb15f3c4af0c5d5738883561 to your computer and use it in GitHub Desktop.
Save alisonailea/1e50939fcb15f3c4af0c5d5738883561 to your computer and use it in GitHub Desktop.
Check publish output of a package in the monorepo
// 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