automated-update.js 816 B

123456789101112131415161718192021222324252627
  1. require('shelljs/global');
  2. if (!which('git')) {
  3. echo('Sorry, this script requires git');
  4. exit(1);
  5. }
  6. if (!which('npm')) {
  7. echo('Sorry, this script requires npm');
  8. exit(1);
  9. }
  10. exec('npm run build', {silent:true});
  11. exec('git status', {silent:true}, function(code, stdout, stderr) {
  12. const indexHasUpdated = stdout.split('\n')[2] !== 'nothing to commit, working directory clean';
  13. if(indexHasUpdated) {
  14. exec('git add versions.js full-versions.js', {silent:true});
  15. exec('git commit -m "generate new version"', {silent:true});
  16. exec('npm version patch', {silent:true});
  17. exec('git push origin master', {silent:true});
  18. exec('git push --tags', {silent:true});
  19. exec('npm publish', {silent:true});
  20. echo('new version released.');
  21. } else {
  22. echo('nothing to do.');
  23. exit(0);
  24. }
  25. });