Created
April 16, 2015 15:14
-
-
Save OmerHerera/ae119b391e084297952f 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
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