openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.18 kB
JavaScript
import{t as formatCliCommand}from"./command-format-D7KhNLP0.mjs";import{n as quotePowerShellArg,t as quoteCliArg}from"./quote-cli-arg-BUHoGELl.mjs";
//!src/cli/installation-target-format.ts
function formatInstallationTargetCommand(e,t,n={}){const r=process.platform===`win32`;const quote=e=>r?quotePowerShellArg(e):`'${e.replaceAll(`'`,`'\\''`)}'`;const i=formatCliCommand(e.map(e=>r?/^[a-z0-9_-]+$/iu.test(e)?e:quote(e):quoteCliArg(e)).join(` `),n.env);const a=[[`OPENCLAW_STATE_DIR`,t.stateDir],[`OPENCLAW_CONFIG_PATH`,t.configPath],[`OPENCLAW_WORKSPACE_DIR`,t.defaultWorkspaceDir]];if(!r)return`env ${a.map(([e,t])=>`${e}=${quote(t)}`).join(` `)} ${i}${n.stdinPath?` < ${quote(n.stdinPath)}`:``}`;const o=a.map(([e])=>`$env:${e}`).join(`, `);const s=a.map(([e,t])=>`$env:${e}=${quote(t)};`).join(` `);const c=a.map(([e],t)=>`$env:${e}=$previousTarget[${t}];`).join(` `);return`& { $previousTarget=@(${o}); try { ${s} ${n.stdinPath?`$prompt=Get-Content -Raw -Encoding UTF8 -LiteralPath ${quote(n.stdinPath)} -ErrorAction Stop; $OutputEncoding=[System.Text.UTF8Encoding]::new(); $prompt | & ${i}`:`& ${i}`} } finally { ${c} } }`}export{formatInstallationTargetCommand as t};