openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 976 B
JavaScript
import{l as pathExists}from"./fs-safe-Bxzu1j4h.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{n as assertCanonicalPathWithinBase,o as resolveSafeInstallDir}from"./install-safe-path-muBIhnx6.mjs";import fs from"node:fs/promises";
//!src/infra/install-target.ts
async function resolveCanonicalInstallTarget(e){await fs.mkdir(e.baseDir,{recursive:true});const t=resolveSafeInstallDir({baseDir:e.baseDir,id:e.id,invalidNameMessage:e.invalidNameMessage,nameEncoder:e.nameEncoder});if(!t.ok)return{ok:false,error:t.error};try{await assertCanonicalPathWithinBase({baseDir:e.baseDir,candidatePath:t.path,boundaryLabel:e.boundaryLabel})}catch(e){return{ok:false,error:formatErrorMessage(e)}}return{ok:true,targetDir:t.path}}async function ensureInstallTargetAvailable(e){if(e.mode===`install`&&await pathExists(e.targetDir))return{ok:false,error:e.alreadyExistsError};return{ok:true}}export{resolveCanonicalInstallTarget as n,ensureInstallTargetAvailable as t};