Skip to content

Commit

Permalink
pre-latest
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Jan 30, 2015
1 parent 124c94a commit 58bee8b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
37 changes: 32 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
*/

'use strict';

var path = require('path')
var path = require('path');
var fmt = require('util').format;
var execCmd = require('exec-cmd');
// var del = require('rimraf-then'); // ????
var run = require('exec-cmd');
// var cwd = require('cwd'); // ????
var stringify = require('stringify-github-short-url');
var handleArguments = require('handle-arguments');

var errs = require('handle-errors')('gitclone');
var errs = require('handle-errors')('gitclone', true);
var error = errs.error;
var type = errs.type;

Expand All @@ -23,9 +24,32 @@ module.exports = function gitclone() {
var args = checkArguments(argz.args);
args = buildArguments(args);

return execCmd(args.cmd, args.opts, argz.callback);
return run(args.cmd, args.opts, argz.callback)
// .then(checkoutBranch(args));
};

// workaround for branching
function checkoutBranch(args) {
return function _then(res) {
if (args.res.branch) {
var root = cwd();
process.chdir(cwd(args.dest));
var cmd = 'git checkout ' + args.res.branch;

return run(cmd, {stdio: [null, null, null]}).catch(function(err) {
console.log(root + '/' + args.dest);
del(root + '/' + args.dest)
return res;
})
}
return res;
}
}

function checkBranchExist(pattern) {

}

/**
* > Build and structure normalized arguments.
*
Expand All @@ -41,7 +65,10 @@ function buildArguments(args) {
var cmd = fmt('%s %s%s/%s.git', git, url, data.user, data.repo);
cmd = dest ? fmt('%s %s', cmd, dest) : cmd;

args.dest = dest ? dest : data.repo;
args.cmd = cmd;
args.cmd = data.branch ? fmt('%s -b %s', cmd, data.branch) : cmd;
// args.cmd = data.branch ? fmt('%s -b %s', cmd, data.branch) : cmd;
args.opts.stdio = args.opts.stdio ? args.opts.stdio : 'inherit';
return args;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"stringify-github-short-url": "~1.0.3"
},
"devDependencies": {
"bluebird": "^2.9.3",
"bluebird": "^2.4.1",
"istanbul-harmony": "^0.3.1",
"mocha": "*",
"mocha-lcov-reporter": "^0.0.1"
Expand Down

0 comments on commit 58bee8b

Please sign in to comment.