openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 2.72 kB
JavaScript
import{n as e}from"./attachment-processor.worker-src-Bd661ObH.mjs";const t=e(import.meta.url),n=/^node(?:-\d+|\d+)(?:\.\d+)*(?:\.exe)?$/;function normalizeRuntimeBasename(e){let t=e.trim().replace(/^["']|["']$/g,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1)).trim().toLowerCase()}function isNodeRuntime(e){let t=normalizeRuntimeBasename(e);return/^node(?:js)?(?:\.exe)?$/.test(t)||n.test(t)}function isBunRuntime(e){let t=normalizeRuntimeBasename(e);return t===`bun`||t===`bun.exe`}const r=/* @__PURE__ */ new Set([`-r`,`--preload`,`--require`,`--import`,`--loader`,`--experimental-loader`,`--test-reporter`,`--test-global-setup`]),i=/* @__PURE__ */ new Set([...r,`-C`,`--env-file`,`--env-file-if-exists`,`--tsconfig`,`--cwd`,`--conditions`,`--icu-data-dir`,`--openssl-config`,`--title`,`--disable-warning`,`--disable-proto`,`--cpu-prof-name`,`--max-old-space-size`,`--max-semi-space-size`]),a=/* @__PURE__ */ new Set([`--inspect`,`--inspect-brk`,`--inspect-wait`,`--expose-gc`,`--jitless`,`--no-opt`,`--experimental-strip-types`,`--watch`,`--no-warnings`,`--trace-uncaught`,`--bun`]);function resolveRuntimeScriptPosition(e){let t=[],n=e[0]??``,o=n.replaceAll(`\\`,`/`).trim().toLowerCase().split(`/`).at(-1),s=isBunRuntime(n),c=o===`tsx`||o===`tsx.cmd`,l=s?`run`:c?`watch`:void 0,u,d=[];if(!isNodeRuntime(n)&&!s&&!c)return{position:{kind:`not-runtime`},operands:t,sourceIndices:d};for(let n=1;n<e.length;n++){let o=e[n];if(o===`--`){if(!u)return{position:d.length===0&&e[n+1]?n+1:{kind:`other`},operands:t,sourceIndices:d};t.push(...e.slice(n+1).map(e=>({value:e,module:!1})));break}if(o===`-e`||o===`-p`||/^--(?:eval|print|run)(?:=|$)/.test(o)){o.includes(`=`)||n++,d.push(n);continue}let c=o.indexOf(`=`),f=c<0?o:o.slice(0,c);if(o.startsWith(`-r`)&&!o.startsWith(`--`)&&o.length>2)t.push({value:o.slice(2),module:!0});else if(i.has(f)){let i=c<0?e[++n]??``:o.slice(c+1),a=!s&&f===`--test-reporter`&&/^(?:dot|spec|tap)$/.test(i);r.has(f)&&!a&&(!s||f!==`--loader`)&&t.push({value:i,module:!0})}else if(o.startsWith(`-`)){let e=`--no-${f.replace(/^--(?:no-)?/,``)}`,n=!s&&process.allowedNodeEnvironmentFlags.has(f),r=a.has(f)||s&&(f===`--hot`||f===`--no-install`)||n&&process.allowedNodeEnvironmentFlags.has(e);d.length===0&&!r&&!/^--[^=]+=/.test(o)&&(u??={kind:`unclassified`,reason:`unsupported runtime option ${o}`}),c>=0&&!r&&!n&&t.push({value:o.slice(c+1),module:!0})}else if(d.length===0&&o===l)l=void 0;else if(d.length===0){if(!u)return{position:n,operands:t,sourceIndices:d};l=void 0,t.push({value:o,module:!1})}else break}return{position:u??{kind:`other`},operands:t,sourceIndices:u?[]:d}}export{t as i,isNodeRuntime as n,resolveRuntimeScriptPosition as r,isBunRuntime as t};