js-to-sh
Version:
Turn javascript code into shellscript
16 lines (15 loc) • 20.5 kB
JavaScript
import{Rgb as T}from"@loggings/beta";var a=class e{constructor(t){this.interaction=t;e.all.set(this.interaction.type,this)}static all=new Map;static get(t){return this.all.get(t)}subprocess(t,s,r){if(t===void 0)throw new Error("Not identified methodType");let o=e.all.get(t);if(o===void 0)return console.debug(`[${t}] Not identified`),"";let n=o.interaction.parser(s,{parser:o.interaction.parser,type:o.interaction.type,subprocess:o.subprocess,data:r});return console.debug(T(255,220,0)+`[${t}] `+T(0,224,255)+n),n}};new a({type:"ArrayExpression",parser(e,t){return e.elements.map(r=>r===null?"":t.subprocess(r.type,r))}});import{Colors as D,Rgb as g}from"@loggings/beta";function l(e){let t="",s=e.filter(r=>typeof r=="string"?r.length!==0:!0);for(let r=0;r<s.length;r++)typeof s[r]=="string"&&s[r].length===0||(t+=s[r],r!==s.length-1&&(t+=`
`));return t}import R from"abstract-syntax-tree";import{readFileSync as O}from"fs";import{join as P}from"path";var i=class e{static tabs=0;static options;static globalDeclarations={};ast;constructor(t){e.options={...t,path:P(t.cwd??"",t.path)},this.ast=e.loader(),global.loggings.config({format:"{message}",level:e.options?.debug?"debug":"info"}),console.debug(g(249,248,113)+"Debug Mode!"),console.debug(g(132,94,194)+"Transpiling:",g(255,199,95)+e.options.path)}static loader(t){return t===void 0&&(t=O(e.options.path,{encoding:"utf-8"})),new R(t)}parser(t){let s=[];t=t??this.ast,s.push(`#!/bin/bash
`);for(let r of t.body){let o=a.all.get(r.type);if(o===void 0){console.debug(g(255,220,0)+`[${r.type}] `+D("red","Not defined"));continue}let n=o.interaction.parser(r,{type:o.interaction.type,parser:o.interaction.parser,subprocess:o.subprocess});for(let[,p]of Object.entries(e.globalDeclarations))s.push(p);e.globalDeclarations={},s.push(n)}return l(s)}static parseOperator(t){return t==="==="||t==="=="?"==":["!==","!="].includes(t)?"!=":t===">"?"-gt":t===">="?"-ge":t==="<"?"-lt":t==="<="?"-le":t}static parseReturnString(t,s){switch(t){case"Identifier":return`"$${s}"`;case"Literal":return Number.isNaN(Number(s))?`"${s}"`:`${s}`;case"CallExpression":return`$(${s})`;case"ArrayExpression":return`(${s.join(" ")})`;case"ArrowFunctionExpression":return`${s}`;case"ObjectExpression":return`${s}`}return`"${s}"`}};function c(e){return" ".repeat(e)}new a({type:"ArrowFunctionExpression",parser(e,t){let s=[],r=t.subprocess(e.body.type,e.body),o=e.params.map(n=>t.subprocess(n.type,n));for(let[n,p]of Object.entries(o))s.push(c(i.tabs)+`local ${p}=$${Number(n)+1}`);return s.push(r),l(s)}});new a({type:"AwaitExpression",parser(e,t){return t.subprocess(e.argument.type,e.argument)}});new a({type:"BinaryExpression",parser(e,t){let s=t.subprocess(e.left.type,e.left),r=t.subprocess(e.right.type,e.right),o=i.parseOperator(e.operator),n=`${i.parseReturnString(e.left.type,s)} ${o} ${i.parseReturnString(e.right.type,r)}`;return o==="+"?`$(( ${n} ))`:`[[ ${n} ]]`}});import{existsSync as q,readFileSync as $}from"fs";import{globSync as E}from"glob";import{basename as F,dirname as L,join as j}from"path";import{fileURLToPath as M}from"url";var I=F(M(import.meta.url)),S=L(M(import.meta.url)),C=()=>I==="index.js"?E(j(S,"..","transformers/**/*.sh"),{cwd:j("..",S)}):E("src/transformers/shellscript/**/*.sh",{cwd:process.cwd()});import{basename as U}from"path";new a({type:"CallExpression",parser(e,t){if(e.callee.type==="MemberExpression"){let s=e.callee,r=e.arguments;return t.subprocess(s.type,s,r.map(o=>i.parseReturnString(o.type,t.subprocess(o.type,o))).join(" "))}else{let s=e.callee.name,r={};switch(C().map(p=>Object.assign(r,{[U(p)]:p})),s){case"fetch":{let p=$(r["fetch.sh"],{encoding:"utf-8"}),m=$(r["isCommand.sh"],{encoding:"utf-8"});i.globalDeclarations=Object.assign({isCommand:m,fetch:p},i.globalDeclarations);break}}let o=e.arguments.map(p=>i.parseReturnString(p.type,t.subprocess(p.type,p))),n=r[`${s}.sh`];if(q(n)){let p=$(n,{encoding:"utf-8"});i.globalDeclarations=Object.assign(i.globalDeclarations,{[s]:p})}return`${s} ${o.length>0?o.join(" "):""}`}}});import{Colors as B}from"@loggings/beta";new a({type:"ClassDeclaration",parser(e,t){return new d(e,t).parseClassDeclaration()}});var d=class e{constructor(t,s){this.options=s;this.AST=t,this.className=this.getClassName(this.AST),this.variables=this.getVariables(this.AST),e.all.set(this.className,this)}static all=new Map;AST;className;constant="";variables;uuid=crypto.randomUUID().replaceAll("-","");getClassName(t){if(t.id===null)throw new Error("[getClassName] classs.id is null");return this.options.subprocess(t.id.type,t.id)}getVariables(t){let s=[];for(let r of t.body.body)if(r.type==="MethodDefinition"){let o=r,{variables:n}=this.parseClassMethodDefinition(o);s.push(...n)}return s}parseClassDeclaration(){let t=[];i.tabs++;let s=/START_CONSTRUCTOR([\s\S]*?)END_CONSTRUCTOR/g;t.push(`
${c(i.tabs-1)}function ${this.className}_new () {`),t.push(`${c(i.tabs)}local self=$1`);let r=s.exec(this.parseClassBody(this.AST.body))?.[1].trim();t.push(r?c(i.tabs)+r:""),i.tabs--,t.push(`${c(i.tabs)}}`);let n=this.parseClassBody(this.AST.body).replace(s,"").replaceAll("(CLASS)",this.className+"_").toString().replaceAll("local self=$1",`local self=$1
${this.variables.map(p=>`${c(i.tabs+1)}local ${p}=$(eval echo \\$$$self"_${p}")
`).join("")}`);return t.push(n),l(t)}parseClassFunctionExpression(t){return t.params.map(r=>this.options.subprocess(r.type,r))}parseClassBody(t){let s=[];for(let r of t.body)switch(r.type){case"FunctionExpression":break;case"MethodDefinition":{let{code:o}=this.parseClassMethodDefinition(r);s.push(o);break}default:console.debug(B("red",`[parseClassBody] ${r.type}`))}return l(s)}parseClassMethodDefinition(t){let s=[],r=[];if(t.key===null)throw new Error("[parseClassMethodDefinition] element.key is null");let o=this.options.subprocess(t.key.type,t.key),n=2;switch(t.kind){case"method":{let p=this.options.subprocess(t.value.type,t.value);s.push(`${c(i.tabs)}function (CLASS)${o} {`),i.tabs++,s.push(`${c(i.tabs)}local self=$1`),s.push(`${c(i.tabs)}${p}`),i.tabs--,s.push(`${c(i.tabs)}}`);break}case"get":break;case"set":break;case"constructor":{let p=this.parseClassFunctionExpression(t.value);s.push("START_CONSTRUCTOR");for(let m of p)r.push(m),s.push(`${c(i.tabs)}eval "$self"_${m}='$${n++}'`);s.push("END_CONSTRUCTOR")}}return{code:l(s),variables:r}}parseAssignmentExpression(t){let s=this.options.subprocess(t.right.type,t.right);return`${c(i.tabs)}${s}`}};new a({type:"FunctionExpression",parser(e,t){return e.body===void 0||e.body===null?(console.debug("[FunctionExpression] is null"),""):t.subprocess(e.body?.type,e.body)}});new a({type:"Identifier",parser(e){return e.name}});new a({type:"Literal",parser(e){return e.value}});import{Colors as W}from"@loggings/beta";var y=class e{options;static tabs=0;constructor(t){this.options=Object.assign(t,{variable:t.variable?.replaceAll('"',"")??void 0})}parse(){return this.map()}map(){switch(this.options.methodName){case"clear":return"clear";case"debug":case"log":case"info":case"warn":case"error":return`${c(i.tabs)}echo "${c(e.tabs)}${this.options.variable}"`;case"count":return this.handleCount();case"countReset":return this.resetCount();case"group":return e.tabs=e.tabs+1,"";case"groupCollapsed":return e.tabs=e.tabs+1,"";case"groupEnd":return e.tabs=e.tabs-1,"";case"time":return this.time();case"timeEnd":return this.timeEnd();default:return'echo "Unknown console method:"'}}handleCount(){let t=[],s=this.options.variable||"default";return t.push(`((count_${s}++))`),t.push(`echo "${c(e.tabs)}${s}: $count_${s}"`),l(t)}resetCount(){let t=[],s=this.options.variable||"default";return t.push(`((count_${s}=0))`),t.push(`echo "${c(e.tabs)}${s}: $count_${s}"`),l(t)}time(){return`((start_time_${this.options.variable||"default"}=$(date +%s%N)))`}timeEnd(){let t=[],s=this.options.variable||"default";return t.push(`((end_time_${s}=$(date +%s%N)))`),t.push(`echo "${c(e.tabs)}${s}: $((($end_time_${s}-start_time_${s})/1000000)) ms"`),l(t)}};new a({type:"MemberExpression",parser(e,t){let s=t.data;if(e.object.type==="MetaProperty")return t.subprocess(e.object.type,e.object,e.property);let r=[],o=e.object.name,n=e.property.name;if(o===void 0)return i.parseReturnString(e.property.type,n);let p=d.all.entries(),m;for(let[,u]of p)u.constant===o&&(m=u.className);if(m!==void 0)return r.push(`${m}_${n} $${o}`),l(r);switch(o){case"console":{r.push(new y({methodName:n,variable:s}).parse());break}default:console.debug(W("red",`[parseMemberExpression] Not identified: ${o}.${n}`)),r.push(`${o}.${n}`)}return l(r)}});import{Colors as J}from"@loggings/beta";new a({type:"MetaProperty",parser(e,t){let s=t.subprocess(e.meta.type,e.meta),r=t.subprocess(e.property.type,e.property),o=t.data;if(o===void 0)throw new Error("[MetaProperty] property is undefined");let n=t.subprocess(o.type,o);switch(`${s}.${r}.${n}`){case"import.meta.dirname":return'$(dirname "$(realpath "$0")")';default:console.debug(J("red",`[parseMetaProperty] Not identified: ${s}.${r}.${n}`))}return""}});new a({type:"NewExpression",parser(e,t){let s=t.subprocess(e.callee.type,e.callee),r=e.arguments.map(o=>i.parseReturnString(o.type,t.subprocess(o.type,o)));return`${s}_new (ARG) ${r.join(" ")}`}});new a({type:"ObjectExpression",parser(e,t){let s=e.properties.map(n=>t.subprocess(n.type,n)).map(([n,p,m])=>[n,i.parseReturnString(m,p)]),r=[],o=[];for(let n=1;n<7;n++){r[n-1]=void 0;for(let[p,m]of s)switch(n){case 2:{p==="method"&&(r[0]=m);break}case 3:{p==="headers"&&(r[1]=m);break}case 4:{p==="body"&&(r[2]=m);break}case 5:{p==="redirect"&&(r[3]=m);break}case 6:{p==="referrer"&&(r[4]=m);break}case 7:{p==="credentials"&&(r[5]=m);break}}}for(let n of r)o.push(n||'""');return o.join(" ")}});new a({type:"PrivateIdentifier",parser(e){return e.name}});new a({type:"TemplateLiteral",parser(e,t){let s=[];for(let[r,o]of Object.entries(e.quasis))if(s.push(o.value.raw),Number(r)<e.expressions.length){let n=e.expressions[Number(r)],p=i.parseReturnString(n.type,t.subprocess(n.type,n));s.push(p)}return s.join("")}});new a({type:"Property",parser(e,t){let s=t.subprocess(e.key.type,e.key),r=t.subprocess(e.value.type,e.value);return[s,r,e.value.type]}});new a({type:"BlockStatement",parser(e,t){let s=[];for(let r of e.body){let o=t.subprocess(r.type,r);if(Array.isArray(o)){s.push(...o);continue}s.push(o)}return l(s)}});new a({type:"BreakStatement",parser(e,t){return e?.label===null?(console.debug("[BreakStatement]: Label is null"),""):t.subprocess("Identifier",e.label)}});new a({type:"ElseStatement",parser(e,t){let s=[];if(e.type!=="IfStatement"){s.push(c(i.tabs-1)+"else");let r=t.subprocess(e.type,e);return Array.isArray(r)?r.map(o=>s.push(o)):s.push(r),l(s)}return s.push(`elif [[ ${t.subprocess(e.test.type,e.test)} ]]; then`),s.push(`${c(i.tabs)}${t.subprocess(e.consequent.type,e.consequent)}`),e.alternate&&s.push(t.subprocess(e.alternate.type,e.alternate)),l(s)}});new a({type:"ExpressionStatement",parser(e,t){let s=[],r=e.expression;return s.push(t.subprocess(r.type,r)),l(s)}});new a({type:"ForOfStatement",parser(e,t){let s=[],r=t.subprocess(e.left.type,e.left),o=t.subprocess(e.right.type,e.right),n=t.subprocess(e.body.type,e.body);return s.push(`
${c(i.tabs)}for ${r} in "\${${o}[@]}"; do`),i.tabs=i.tabs+1,s.push(c(i.tabs)+n),i.tabs=i.tabs-1,s.push(`${c(i.tabs)}done`),l(s)}});new a({type:"FunctionDeclaration",parser(e,t){if(e.id===null||e.body===null||e.body===void 0)return console.debug("[FunctionDeclaration] node.id is null"),"";let s=[],r=e.params.map(n=>t.subprocess(n.type,n)),o=t.subprocess(e.id?.type,e.id);s.push(`function ${c(i.tabs)}${o}() {`),i.tabs++;for(let[n,p]of Object.entries(r))s.push(`${c(i.tabs)}local ${p}=$${Number(n)+1}`);return s.push(t.subprocess(e.body.type,e.body)),i.tabs--,s.push(c(i.tabs)+`}
`),l(s)}});new a({type:"IfStatement",parser(e,t){i.tabs++;let s=t.subprocess(e.test.type,e.test),r=t.subprocess(e.consequent.type,e.consequent),o=a.get("ElseStatement"),n=e.alternate?o.interaction.parser(e.alternate,{parser:o.interaction.parser,type:o.interaction.type,subprocess:o.subprocess}):"",p=[];return p.push(`${i.tabs>=1?`
`:""}if ${s}; then`),p.push(r),n.length>0&&p.push(n),p.push(`fi${i.tabs>=1?`
`:""}`),i.tabs--,l(p)}});import{dirname as _,join as v,resolve as V}from"path";import{existsSync as G,readFileSync as K}from"fs";import{Colors as z}from"@loggings/beta";new a({type:"ImportDeclaration",parser(e,t){let s=t.subprocess(e.type,e),r=_(V(i.options.path));if(!G(v(r,s)))throw new Error(z("red",`[${s}] It is not possible to use external or internal packages.`));let o=v(r,s.replace("javascript","shellscript").replace(".js",".sh"));return K(o,{encoding:"utf-8"})}});new a({type:"ReturnStatement",parser(e,t){if(e.argument===null)return console.debug("[ReturnStatement] node.argument is null"),"";let s=t.subprocess(e.argument.type,e.argument);return`echo ${i.parseReturnString(e.argument.type??"Literal",s)}`}});new a({type:"SwitchStatement",parser(e,t){let s=[],r=t.subprocess(e.discriminant.type,e.discriminant);s.push(`${c(i.tabs)}case $${r} in`),i.tabs++;for(let o of e.cases){if(i.tabs++,o.test){let n=t.subprocess(o.test.type,o.test);s.push(`${c(i.tabs)}"${n}")`)}else s.push(c(i.tabs)+"*))");i.tabs++,s.push(c(i.tabs)+l(o.consequent.map(n=>t.subprocess(n.type,n)))),s.push(c(i.tabs)+";;"),i.tabs--,i.tabs--}return s.push(c(i.tabs)+"esac"),i.tabs--,l(s)}});import{Colors as X}from"@loggings/beta";new a({type:"VariableDeclaration",parser(e,t){let s=[];for(let r of e.declarations){let o=t.subprocess(r.id.type,r.id);if(r.init===null){s.push(o);continue}r.init.type==="ArrowFunctionExpression"&&i.tabs++;let n=t.subprocess(r.init.type,r.init);r.init.type==="ArrowFunctionExpression"&&i.tabs--;let p=i.parseReturnString(r.init.type==="AwaitExpression"?r.init.argument.type:r.init.type??"Literal",n);if(p.includes("(ARG)")&&r.init.type==="NewExpression"){let m=t.subprocess(r.init.callee.type,r.init.callee),u=d.all.get(m);u===void 0?console.debug(X("red",`[${m}] Not implemented`)):u.constant=o,s.push(`
${o}="${m}_${crypto.randomUUID().replaceAll("-","")}"`),s.push(n.replaceAll("(ARG)",`$${o}`)+`
`);continue}r.init.type==="ArrowFunctionExpression"?(s.push(`function ${o} () {`),s.push(p),s.push("}")):s.push(`${o}=${p}`)}return l(s)}});import{stat as H}from"fs/promises";var Q=async e=>{try{return(await H(e)).isDirectory()}catch{return!1}};global.isDir=Q;var Y=e=>{switch(typeof e){case"undefined":return!0;default:return!1}};global.isEmpty=Y;import{access as Z,constants as ee}from"fs/promises";var te=async e=>{try{return await Z(e,ee.X_OK),!0}catch{return!1}};global.isExecutable=te;import{stat as se}from"fs/promises";var re=async e=>{try{return(await se(e)).isFile()}catch{return!1}};global.isFile=re;var oe=e=>!Number.isNaN(Number(e));global.isNumber=oe;import{access as ie,constants as ne}from"fs/promises";var ae=async e=>{try{return await ie(e,ne.R_OK),!0}catch{return!1}};global.isReadable=ae;import{access as pe,constants as ce}from"fs/promises";var le=async e=>{try{return await pe(e,ce.W_OK),!0}catch{return!1}};global.isWritable=le;import{exec as me}from"child_process";import{promisify as ue}from"util";var de=async e=>{try{let t=ue(me),{stdout:s}=await t(`command -v ${e}`);return s.length!==0}catch{return!1}};global.isCommand=de;var fe=fetch,be=async(e,t)=>await fe(e,t);global.fetch=be;import{Colors as N,Loggings as x,LoggingsRegister as ye,Rgb as $e}from"@loggings/beta";import{mkdir as we,writeFile as k}from"fs/promises";import{glob as xe}from"glob";import{basename as Te,dirname as Ee,join as w}from"path";import{fileURLToPath as je}from"url";var A={name:"js-to-sh",description:"Turn javascript code into shellscript",version:"1.2.1",main:"dist/cjs/index.cjs",module:"dist/mjs/index.js",types:"dist/types/index.d.ts",typings:"dist/types/index.d.ts",type:"module",bin:{tjss:"dist/cjs/index.cjs","transpiler-js-shell":"dist/cjs/index.cjs","js-to-sh":"dist/cjs/index.cjs"},typesVersions:{"*":{".":["./dist/types/index.d.ts"],globals:["./dist/types/index.d.ts"]}},exports:{".":{types:"./dist/types/index.d.ts",import:"./dist/mjs/index.js",require:"./dist/cjs/index.cjs"},"./globals":{types:"./dist/types/index.d.ts",import:"./dist/types/index.d.ts",require:"./dist/types/index.d.js"},"./loader":{types:"./dist/types/index.d.ts",import:"./dist/mjs/index.js",require:"./dist/cjs/index.cjs"}},engines:{node:">=20"},scripts:{cli:"bun src/cli.ts",test:"tsx test/app.ts && chmod 777 output/*",build:"rimraf dist && bun build/build.ts",lint:"eslint -c eslint.config.js"},keywords:["transpiler","javascript","transpiler-js","transpilers","builder","shellscript","js-to-sh","ast","abstract-syntax-tree"],repository:{type:"git",url:"git+https://github.com/Ashu11-A/Transpiler-JS-Shell.git"},author:"Ashu11A",license:"MIT",bugs:{url:"https://github.com/Ashu11-A/Transpiler-JS-Shell/issues"},homepage:"https://github.com/Ashu11-A/Transpiler-JS-Shell",dependencies:{"@loggings/beta":"^2.4.0","abstract-syntax-tree":"^2.22.0",glob:"^11.0.0"},devDependencies:{"@eslint/js":"^9.16.0","@types/node":"^22.10.2",chokidar:"^4.0.1","dts-bundle-generator":"^9.5.1",eslint:"^9.16.0",globals:"^15.13.0",meriyah:"^6.0.3",rimraf:"^6.0.1","tsc-alias":"^1.8.10",tsup:"^8.3.5",tsx:"^4.19.2",typescript:"^5.7.2","typescript-eslint":"^8.18.0"}};import{Colors as f}from"@loggings/beta";var b=class e{static args=[];constructor(t){e.args=t}validate(t){for(let s of t.filter(r=>r.includes("-")))if(!e.args.flatMap(({command:o,alias:n})=>[o,...n.map(p=>p||o)]).includes(s))throw new Error(`Not found arg ${s}, try --help`)}formatAliasToCommand(t){let s=[];for(let r=0;r<t.length;r++)for(let o of e.args)if(o.alias.includes(t[r])||t[r]===o.command){if(o?.hasString){if(t[r+1]?.startsWith("-")){s.push(o);continue}++r,s.push({...o,string:t[r]});continue}s.push(o);continue}return s}quickSort(t){return t.sort((s,r)=>s.rank-r.rank)}static help(){let t=[];t.push(`Usage: ${f("yellow","tjss")} ${f("magenta","[options]")}
`),t.push(` Options:
`);let s=Math.max(...e.args.map(o=>o.alias.join(", ").length)),r=Math.max(...e.args.map(o=>`--${o.command}`.length));for(let o of e.args){let n=o.alias.join(", "),p=`--${o.command}`,m=" ".repeat(s-n.length),u=" ".repeat(r-p.length);t.push(` ${f("blue",n)}${m} ${f("white",p)}${u} ${f("green",o.description)}`)}return t.join(`
`)}async run(t){this.validate(t);let s=this.quickSort(this.formatAliasToCommand(t));if(s.length===0){console.log(e.help());return}for(let r of s)await r.function(r.string)}};x.rem(ye.identify);x.useConsole(new x);var Se=process.argv.slice(2).map(e=>e.replace("--","")),h=new Map;process.argv[1]!==je(import.meta.url)&&!Object.keys(A.bin).includes(Te(process.argv[1]))||new b([{alias:["-h"],command:"help",description:"Show all available arguments",rank:0,async function(){console.log(b.help()),process.exit()}},{alias:["-D"],command:"debug",description:"Activates debug mode.",rank:0,async function(){process.env.transpilerDebug="true"}},{alias:["-d"],command:"dir",description:"Directory for fetching and transpiling .js files",hasString:!0,rank:1,async function(e){if(e===void 0)throw new Error("Dir not expecificate");if(!await isDir(e))throw new Error("Directory specified invalid");let t=await xe(`${e}/**/*.{js,ts}`,{cwd:process.cwd()});for(let s of t){let r=new i({path:s,debug:!1}).parser();h.set(s.split("/").slice(1).join("/"),r)}}},{alias:["-f"],command:"file",description:"File to be transpiled.",rank:1,hasString:!0,async function(e){if(e===void 0)throw new Error("File not expecificate");let t=new i({path:e,debug:JSON.parse(process.env.transpilerDebug??"false")}).parser();h.set(e,t)}},{alias:["-o"],command:"output",description:"Output directory or file to save the transpiled files.",rank:9,hasString:!0,async function(e){if(e===void 0)throw new Error("--output requires an input");let t=h.entries();if(h.size>1&&e.includes(".sh"))throw new Error(`Output was declared to be ${e}, but you passed a directory, it is not possible to process several files and save them in a single file`);for(let[s,r]of t){let o=w(process.cwd(),e);if(e.includes(".sh")){await k(o,r,{encoding:"utf-8"}),console.log(`${N("yellow","Transpiled:")} ${N("blue",s)} \u27A4 ${$e(12,232,41)+e}`);continue}if(h.size>1){await we(Ee(w(o,s)),{recursive:!0}),k(w(o,s).replace(".ts",".sh").replace(".js",".sh"),r,{encoding:"utf-8"});continue}throw new Error(`Output ${e} is invalid!`)}}}]).run(Se);export{a as Method,i as Transpiler,l as breakLines,be as fetchNew,c as getTabs,de as isCommand,Q as isDir,Y as isEmpty,te as isExecutable,re as isFile,oe as isNumber,ae as isReadable,le as isWritable};