SHARE
TWEET

Untitled

a guest Jul 17th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** A simple program to automate pushing code to GitHub.
  2.  *  Add this file in the directory of your Git repository.
  3.  */
  4.  
  5. const cp = require('child_process');
  6. const rl = require('readline');
  7.  
  8. function messagePromise() {
  9.   let input = rl.createInterface(process.stdin, process.stdout);
  10.  
  11.   return new Promise(function(resolve, reject) {
  12.     input.question('Enter commit message: ', function(message) {
  13.       if(message.length > 1)
  14.         resolve(message);
  15.       else
  16.         reject(new Error("You must send a message."));
  17.       input.close();
  18.     });
  19.   });
  20. }
  21.  
  22. const status = cp.execSync('git status').toString();
  23. if(status.includes('nothing to commit'))
  24.   console.log("Nothing to commit");
  25. else {
  26.   messagePromise()
  27.     .then(function(message) {
  28.       console.log(cp.execSync('git add .').toString());
  29.       console.log(cp.execSync(`git commit -m "${message}"`).toString());
  30.       console.log(cp.execSync('git push').toString());
  31.     })
  32.     .catch(function(err) {
  33.       console.log('Abort');
  34.     });
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top