Guest User

Untitled

a guest
Mar 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. const { execSync } = require('child_process');
  2. const fs = require('fs');
  3. const d = process.cwd(); //__dirname;
  4. let pkgInfo = require(d + '/package.json');
  5.  
  6. let ver = pkgInfo.version;
  7. if ( ! ver.match(/-SNAPSHOT$/) ) {
  8. throw new Error("You can't publish non-snapshot version. Sorry");
  9. }
  10.  
  11. ver = ver.replace(/-SNAPSHOT$/i, '');
  12. let tag = 'v' + ver;
  13. pkgInfo.version = ver;
  14.  
  15. fs.writeFileSync(d + '/package.json', JSON.stringify(pkgInfo, null, 2));
  16.  
  17. execSync('/usr/bin/git commit ./package.json -m "Release ' + tag + '" ');
  18. execSync('/usr/bin/git tag -a ' + tag + ' -m "Version ' + ver + '" ');
  19.  
  20. execSync('/usr/bin/git push origin --tags');
Add Comment
Please, Sign In to add comment