publish.js 1015 B

12345678910111213141516171819202122232425262728293031323334
  1. // Dependecies.
  2. const shelljs = require('shelljs');
  3. const colorConsole = require("../../NodeHelpers/colorConsole");
  4. /**
  5. * Publish a package to npm.
  6. */
  7. function publish(version, packageName, publishPath, public) {
  8. colorConsole.log(' Publishing ' + packageName.blue.bold + " from " + publishPath.cyan);
  9. let tag = "";
  10. // check for alpha or beta
  11. if (version.indexOf('alpha') !== -1 || version.indexOf('beta') !== -1 || version.indexOf('rc') !== -1) {
  12. tag = ' --tag preview';
  13. }
  14. //publish the respected package
  15. var cmd = 'npm publish "' + publishPath + '"' + tag;
  16. if (public) {
  17. cmd += " --access public";
  18. }
  19. if (process.env.BABYLONJSREALPUBLISH === "true") {
  20. colorConsole.log(" Executing: " + cmd.yellow);
  21. shelljs.exec(cmd);
  22. }
  23. else {
  24. colorConsole.log(" If publishing enabled: " + cmd.yellow);
  25. }
  26. colorConsole.success(' Publishing ' + "OK".green);
  27. }
  28. module.exports = publish;