From 107e8f2ae66b834d9be3d8981c2f3d68bac9ce67 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 30 Jan 2015 11:46:06 +0100 Subject: [PATCH] Updating dist.js --- dist.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dist.js b/dist.js index 4a15602..e381093 100644 --- a/dist.js +++ b/dist.js @@ -7,19 +7,26 @@ var ncp = Promise.promisify(require('ncp').ncp); var local = 'tmp'; var repo = 'https://github.com/taigaio/taiga-front'; -var action = (function cloneOrPull(){ +if (process.argv.length !== 3){ + console.log("¡Error!, call me with somethink like: \nnode dist.js branch_name"); + process.exit(); +} + +var branch = process.argv[2]; + +var synchRepoAction = (function cloneOrPull(){ var cloned = fs.existsSync(local); if (cloned) { - action = 'cd ' + local + ' && git pull'; + action = 'git checkout ' + branch + '&& cd ' + local + ' && git checkout ' + branch + ' && git pull'; } else { - action = 'git clone ' + repo + ' ' + local; + action = 'git checkout ' + branch + 'git clone -b ' + branch + ' ' + repo + ' ' + local; } return action; }()) -exec(action) +exec(synchRepoAction) .then(function() { //remove old tmp dist return delAsync(local + '/dist'); @@ -48,6 +55,6 @@ exec(action) }) .then(function() { //push - return exec('git push origin master'); + return exec('git push origin ' + branch); }) .done();