UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.19 kB
import{ot as ignoreMissingPath}from"./paths--OfTlHNJ.js";import path from"node:path";import fsPromises from"node:fs/promises";import"@openclaw/fs-safe/path";import fs from"node:fs"; //!src/infra/path-existence.ts function realpathExistingAncestorSync(e){const t=[];let n=e;while(true)try{return path.join(fs.realpathSync.native(n),...t.toReversed())}catch{const e=path.dirname(n);if(e===n)return;t.push(path.basename(n));n=e}}async function realpathExistingAncestor(e){const t=[];let n=e;while(true)try{return path.join(await fsPromises.realpath(n),...t.toReversed())}catch{const e=path.dirname(n);if(e===n)return;t.push(path.basename(n));n=e}}function resolveIdentityPathViaExistingAncestorSync(e){const t=path.resolve(e);return realpathExistingAncestorSync(t)??t}async function resolveIdentityPathViaExistingAncestor(e){const t=path.resolve(e);return await realpathExistingAncestor(t)??t}async function statIfExists(e){return fsPromises.stat(e).catch(ignoreMissingPath)}function canAccessSync(e,t){try{fs.accessSync(e,t);return true}catch{return false}}export{statIfExists as i,resolveIdentityPathViaExistingAncestor as n,resolveIdentityPathViaExistingAncestorSync as r,canAccessSync as t};