jiranch
Version:
Easily create Git branches from your sprint issues
1 lines • 2.42 kB
JavaScript
;var __awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(a,c){function o(e){try{u(n.next(e))}catch(e){c(e)}}function i(e){try{u(n.throw(e))}catch(e){c(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,i)}u((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var r,n,a,c,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return c={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function i(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;c&&(c=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkBranchExists=void 0;var utils_1=require("./utils"),ora_1=__importDefault(require("ora"));function checkBranchExists(e){var t=e.branchName,r=e.skipCheckout;return __awaiter(this,void 0,void 0,(function(){var e,n;return __generator(this,(function(a){switch(a.label){case 0:return[4,(0,utils_1.exec)("git branch --list '".concat(t,"*'"))];case 1:return e=a.sent().stdout,!!e?((0,ora_1.default)("Local branch exists! Skipping creation.").succeed(),e.includes("*")?((0,ora_1.default)("Already on ".concat(t)).succeed(),[3,4]):[3,2]):[3,5];case 2:return r?[3,4]:(n=e.trim(),[4,(0,utils_1.exec)("git checkout ".concat(n))]);case 3:a.sent(),(0,ora_1.default)("Checkout ".concat(n)).succeed(),a.label=4;case 4:process.exit(),a.label=5;case 5:return[2]}}))}))}exports.checkBranchExists=checkBranchExists;