MCPcopy Create free account
hub / github.com/mksglu/context-mode / executeFile

Method executeFile

cli.bundle.mjs:503–503  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

501`)}function DP(t,e){if(e!=="win32")return t;let n=new Set([";","&","|","(",`
502`]),r="",o=!0,s=0;for(;s<t.length;){let i=t[s];if(o&&(i===" "||i===" ")){r+=i,s++;continue}if(o&&t.startsWith("mvn",s)){let a=t[s+3];if(a===void 0||a===" "||a===" "||a===`
503`){r+="mvn.cmd",s+=3,o=!1;continue}}r+=i,o=n.has(i),s++}return r}function RP(t){try{FB(t,{recursive:!0,force:!0,maxRetries:Lt?8:2,retryDelay:100})}catch{}}function K_(t){if(Lt&&t.pid)try{HB(`taskkill /F /T /PID ${t.pid}`,{stdio:"pipe"})}catch{}else if(t.pid)try{process.kill(-t.pid,"SIGKILL")}catch{}}var Lt,BB,WB,ci,G_=x(()=>{"use strict";Yo();Lt=process.platform==="win32",BB={javascript:"js",typescript:"ts",python:"py",shell:"sh",ruby:"rb",go:"go",rust:"rs",php:"php",perl:"pl",r:"R",elixir:"exs",csharp:"csx"};WB=(()=>{if(Lt)return process.env.TEMP??process.env.TMP??ZB();try{let t=CP(process.platform==="darwin"?"getconf":"mktemp",process.platform==="darwin"?["DARWIN_USER_TEMP_DIR"]:["-u","-d"],{env:{...process.env,TMPDIR:void 0},encoding:"utf-8"}).trim(),e=process.platform==="darwin"?t:OP(t,"..");if(e&&e!==process.cwd())return e}catch{}return"/tmp"})();ci=class{#e;#t;#n;#o=new Set;constructor(e){this.#e=e?.hardCapBytes??100*1024*1024;let n=e?.projectRoot;typeof n=="function"?this.#t=n:typeof n=="string"?this.#t=()=>n:this.#t=()=>process.cwd(),this.#n=e?.runtimes??Xr()}get#s(){return this.#t()}get runtimes(){return{...this.#n}}cleanupBackgrounded(){for(let e of this.#o)try{process.kill(Lt?e:-e,"SIGTERM")}catch{}this.#o.clear()}async execute(e){let{language:n,code:r,timeout:o,background:s=!1,cwd:i}=e,a=UB(Gl(WB,".ctx-mode-"));try{let c=this.#a(a,r,n),u=Xd(this.#n,n,c);if(u[0]==="__rust_compile_run__")return await this.#c(c,a,o);let l=i??this.#s,d=await this.#i(u,l,a,o,s);return d.backgrounded||RP(a),d}catch(c){throw RP(a),c}}async executeFile(e){let{path:n,language:r,code:o,timeout:s}=e,i=OP(this.#s,n),a=this.#l(i,r,o);return this.execute({language:r,code:a,timeout:s})}#a(e,n,r){r==="go"&&!n.includes("package ")&&(n=`package main
504
505import "fmt"
506

Callers 7

cli.bundle.mjsFile · 0.45
mainFunction · 0.45
mainFunction · 0.45
executor.test.tsFile · 0.45
mainFunction · 0.45
mainFunction · 0.45
server.test.tsFile · 0.45

Calls 2

executeMethod · 0.65
#lMethod · 0.45

Tested by

no test coverage detected