@lunora/cli
Version:
The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands
2 lines (1 loc) • 795 B
JavaScript
import{spawn as i}from"node:child_process";import{platform as s}from"node:os";import{LunoraError as a}from"@lunora/errors";const d=()=>{const o=s();return o==="darwin"?{args:[],command:"open"}:o==="win32"?{args:["/c","start",""],command:"cmd"}:{args:[],command:"xdg-open"}},f=o=>o.replaceAll(/[!"%&()<>^|]/gu,n=>`%${(n.codePointAt(0)??0).toString(16).toUpperCase()}`),w=o=>new Promise((n,r)=>{const{args:e,command:c}=d(),p=s()==="win32"?f(o):o,t=i(c,[...e,p],{detached:!0,stdio:"ignore"});t.once("error",m=>{r(m)}),t.once("spawn",()=>{t.unref(),n()})}),L=async(o,n={})=>{let r;try{r=new URL(o)}catch{throw new a("INTERNAL",`Invalid URL: ${o}`)}if(r.protocol!=="http:"&&r.protocol!=="https:")throw new a("INTERNAL",`Refusing to open non-http(s) URL: ${o}`);await(n.opener??w)(o)};export{L as o};