Last active
May 12, 2020 08:37
-
-
Save cesarvr/7c2d3c329c2ccc4a0649f42099318b46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { spawn } = require('child_process'); | |
function pull(action) { | |
const git = spawn('git', ['pull']) | |
git.stdout.on('data', function(data) { | |
let msg = data.toString() | |
console.log('[git pull]: ', msg) | |
if(!msg.includes('Already up to date.')){ | |
action() | |
} | |
}) | |
git.on('exit', function(data) { | |
console.log('[git pull]: exit ', data) | |
}) | |
} | |
function push(remote, branch) { | |
const git = spawn('git', ['push', remote, branch]) | |
git.stdout.on('data', function(data) { | |
let msg = data.toString() | |
console.log('[git error]: ', data) | |
}) | |
git.on('data', function(data) { | |
console.log('[git push]: ', data) | |
}) | |
git.on('exit', function(data) { | |
console.log('[git push]: exit ', data) | |
}) | |
} | |
pull(() => console.log('do something !! ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment