Skip to content

Instantly share code, notes, and snippets.

@OmerHerera
Created April 16, 2015 15:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save OmerHerera/ae119b391e084297952f to your computer and use it in GitHub Desktop.
Save OmerHerera/ae119b391e084297952f to your computer and use it in GitHub Desktop.
var exec = require('child_process').exec;
function _command (command, cb){
var child = exec(command, function(err, stdout, stderr){
if(err != null){
return cb(new Error(err), null);
}else if(typeof(stderr) != "string"){
return cb(new Error(stderr), null);
}else{
return cb(null, stdout);
}
});
}
async.series(
[
function (callback) {
_command("git clone git@git@github.com:request/request.git", function (err, response) {
if (err) {
return console.log("ERR: " + err);
}
console.log("------------CLONE DONE---------");
callback();
});
},
function (callback) {
_command("git branch new", function (err, response) {
if (err) {
return console.log("ERR: " + err);
}
console.log("------------BRANCH CREATED DONE---------");
callback();
});
},
function (callback) {
_command("git checkout new", function (err, response) {
if (err) {
return console.log("ERR: " + err);
}
console.log("------------CHECKOUT NEW BRANCH DONE---------");
callback();
});
},
function (callback) {
fs.writeFile('message.txt', 'Hello Node', function (err) {
if (err) throw err;
console.log("------------FILE CREATED DONE---------");
callback();
});
},
function (callback) {
_command("git add \"*\"", function (err, response) {
if (err) {
return console.log("ERR: " + err);
}
console.log("------------GIT ADD DONE---------");
callback();
});
},
function (callback) {
_command("git commit -m \"new branch\"", function (err, response) {
if (err) {
return console.log("ERR: " + err);
}
console.log("------------GIT COMMIT DONE---------");
callback();
});
},
function (callback) {
_command("git push origin master", function (err, response) {
if (err) {
return console.log("ERR: " + err);
}
console.log("------------GIT PUSH DONE---------");
callback();
});
}
],
function _allGood(err, results) {
if (err) {
console.log("-------------ERROR-------------")
}
else {
console.log("-------------ALL GOOD-------------")
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment