Skip to content

Instantly share code, notes, and snippets.

@behnammodi
Created February 20, 2019 06:41
Show Gist options
  • Save behnammodi/56b60f6bb286e9b88269b1425ba96fb0 to your computer and use it in GitHub Desktop.
Save behnammodi/56b60f6bb286e9b88269b1425ba96fb0 to your computer and use it in GitHub Desktop.
run git command with nodejs
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