jiranch
Version:
Easily create Git branches from your sprint issues
1 lines • 2.55 kB
JavaScript
;var __awaiter=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))((function(a,o){function i(e){try{c(n.next(e))}catch(e){o(e)}}function u(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?a(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(i,u)}c((n=n.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var t,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(t=1,n&&(a=2&u[0]?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){i.label=u[1];break}if(6===u[0]&&i.label<a[1]){i.label=a[1],a=u;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(u);break}a[2]&&i.ops.pop(),i.trys.pop();continue}u=r.call(e,i)}catch(e){u=[6,e],n=0}finally{t=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.verifyBaseBranch=void 0;var utils_1=require("./utils"),inquirer_1=__importDefault(require("inquirer")),shared_1=require("../shared"),ora_1=__importDefault(require("ora")),mainBranches=["master","main"];function verifyBaseBranch(){return __awaiter(this,void 0,void 0,(function(){var e,r;return __generator(this,(function(t){switch(t.label){case 0:return[4,(0,utils_1.exec)("git branch --show-current")];case 1:return e=t.sent().stdout,mainBranches.some((function(r){return e.includes(r)}))?[3,3]:((0,ora_1.default)().warn("You are not on main branch."),[4,inquirer_1.default.prompt([{type:"boolean",name:"create",message:"Continue creating branch from '".concat(e.replace(/[\s\n]/g,""),"'? (y/n)"),default:"n"}])]);case 2:r=t.sent().create,(0,shared_1.confirmed)(r)||(console.log("Switch to main branch and rerun."),console.log("Aborting..."),process.exit()),t.label=3;case 3:return[2]}}))}))}exports.verifyBaseBranch=verifyBaseBranch;