UNPKG

@yunarch/config-web

Version:

Shared configurations for web projects.

2 lines (1 loc) 893 B
import{execFile as c}from"child_process";import{promisify as p,styleText as t,types as l}from"util";import{Command as u}from"commander";import y from"ora";var h=p(c);async function P(r){let{command:e,name:n,options:m}=r,o=y(n);o.spinner=m?.spinner??"aesthetic";let a=Date.now();o.start();try{let s=l.isPromise(e)?await e:await e();return o.succeed(m?.showTime?`${t("dim",`${Date.now()-a}ms`)} ${n}`:void 0),await new Promise(i=>{setTimeout(i,0)}),s}catch(s){let i=s;throw o.fail(t("red",i.stderr??i.message??"")),s}}function b(){let r=new u;return r.configureHelp({styleTitle:e=>t("bold",e),styleCommandText:e=>t("cyan",e),styleCommandDescription:e=>t("magenta",e),styleDescriptionText:e=>t("italic",e),styleOptionText:e=>t("green",e),styleArgumentText:e=>t("yellow",e),styleSubcommandText:e=>t("blue",e)}).configureOutput({outputError:(e,n)=>{n(t("red",e))}}),r}export{h as a,P as b,b as c};