UNPKG

anl

Version:
2 lines (1 loc) 1.39 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("path"),s=require("progress-estimator"),t=require("./const.js"),i=require("fs"),o=require("shelljs"),c=require("../utils/index.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const r=l(s).default({storagePath:e.join(__dirname,".progress-estimator")});exports.commitlintHanlde=async()=>{o.which("git")||(c.log.warning("Sorry, this script requires git"),o.exit(1));const e=new Promise(((e,s)=>{try{c.spinner.start("commitlint tools instll..."),o.exec(t.COMMIT_VERIFY,{silent:!0}),c.spinner.success("✨ commitlint instll success!"),e({success:!0})}catch(e){s(e)}})),s=!0,l=new Promise(((e,l)=>{try{c.log.load("instll husky..."),o.exec(t.NPM_HUSK,{silent:s}),c.log.success("husk instll done!"),c.log.load("create husky..."),o.exec(t.HUSKY_INSTALL,{silent:s}),c.log.success("husk create done!"),c.log.load("set commit-msg..."),o.exec(t.ADD_COMMIT_MSG,{silent:s}),c.log.success("set commit-msg done!"),c.log.load("create config file..."),i.writeFileSync(`${process.cwd()}/commitlint.config.js`,t.COMMIT_CONFIG_CONTENT),c.log.success("config file write done!"),e({success:!0})}catch(e){c.spinner.error("commitlint instll fail!"),l(e)}}));try{await r(e,"install commit lint tools",{estimate:1e4}),await r(l,"commit config file write")}catch(e){console.log("commitlintHanlde=====>",e)}};