Created
February 20, 2019 06:41
-
-
Save behnammodi/56b60f6bb286e9b88269b1425ba96fb0 to your computer and use it in GitHub Desktop.
run git command with nodejs
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 {exec} = require('child_process'); | |
function git(args) { | |
return new Promise(res => { | |
exec('git ' + args, (err, stdout, stderr) => { | |
if (err) { | |
throw err; | |
} else { | |
res(stdout.trim()); | |
} | |
}); | |
}); | |
} | |
await git('fetch upstream'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment