Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** A simple program to automate pushing code to GitHub.
- * Add this file in the directory of your Git repository.
- */
- const cp = require('child_process');
- const rl = require('readline');
- function messagePromise() {
- let input = rl.createInterface(process.stdin, process.stdout);
- return new Promise(function(resolve, reject) {
- input.question('Enter commit message: ', function(message) {
- if(message.length > 1)
- resolve(message);
- else
- reject(new Error("You must send a message."));
- input.close();
- });
- });
- }
- const status = cp.execSync('git status').toString();
- if(status.includes('nothing to commit'))
- console.log("Nothing to commit");
- else {
- messagePromise()
- .then(function(message) {
- console.log(cp.execSync('git add .').toString());
- console.log(cp.execSync(`git commit -m "${message}"`).toString());
- console.log(cp.execSync('git push').toString());
- })
- .catch(function(err) {
- console.log('Abort');
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement