Files
bower/test/util/fetchBranch.js
2013-04-23 23:38:13 +01:00

15 lines
487 B
JavaScript

var cmd = require('../../lib/util/cmd');
function fetchBranch(branch, dir) {
return cmd('git', ['checkout', '-b', branch, 'origin/' + branch], { cwd: dir })
.then(null, function (err) {
if (/already exists/i.test(err.details)) {
return cmd('git', ['checkout', branch], { cwd: dir })
.then(function () {
return cmd('git', ['pull', 'origin', branch], { cwd: dir });
});
}
});
}
module.exports = fetchBranch;