UNPKG

@nice-move/cli

Version:
2 lines 1.29 kB
import{source_default as e}from"./source-DtPIOlG2.mjs";const t=[` `,`⚠`,`✖`],n=[`white`,`yellow`,`red`];function r(e={},t={}){let{results:n=[]}=e,r=e=>i(e,t),o=e=>a(e,t);return n.filter(e=>Array.isArray(e.warnings)||Array.isArray(e.errors)).map(e=>[...r(e),...o(e)]).reduce((e,t)=>Array.isArray(t)?[...e,...t]:[...e,t],[]).join(` `)}function i(t,n={}){let{color:r=!0}=n,{errors:i=[],warnings:a=[],input:o=``}=t;if(!o)return[``];let s=`⧗`,c=r?e.gray(s):s,l=r?e.bold(o):o,u=i.length>0||a.length>0;return n.verbose||u?[`${c} input: ${l}`]:[]}function a(r={},i={}){let{signs:a=t,colors:o=n,color:l=!0}=i,{errors:u=[],warnings:d=[]}=r,f=[...u,...d].map(t=>{let n=a[t.level]||``,r=o[t.level]||`white`,i=l?e[r](n):n,s=l?e.grey(`[${t.name}]`):`[${t.name}]`;return`${i} ${t.message} ${s}`}),p=s(r),m=c(r),h=l?e[m](p):p,g=u.length,_=d.length,v=f.length>0,y=i.verbose||v?`${h} found ${g} problems, ${_} warnings`:void 0,b=l&&typeof y==`string`?e.bold(y):y,x=v&&i.helpUrl?`ⓘ Get help: ${i.helpUrl}`:void 0;return[...f,v?``:void 0,b,x,v?``:void 0].filter(e=>typeof e==`string`)}var o=r;function s(e){return(e.errors||[]).length>0?`✖`:(e.warnings||[]).length?`⚠`:`✔`}function c(e){return(e.errors||[]).length>0?`red`:(e.warnings||[]).length?`yellow`:`green`}export{o as default};