openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.31 kB
JavaScript
import{n as ignoreMissingPath}from"./errno-DUBt6SQQ.mjs";import fsSync from"node:fs";import"@openclaw/fs-safe/path";import path from"node:path";import fsPromises from"node:fs/promises";
//!src/infra/path-existence.ts
function realpathExistingAncestorSync(e){const t=[];let n=e;while(true)try{return path.join(fsSync.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)}async function canAccess(e,t){try{await fsPromises.access(e,t);return true}catch{return false}}function canAccessSync(e,t){try{fsSync.accessSync(e,t);return true}catch{return false}}export{statIfExists as a,resolveIdentityPathViaExistingAncestorSync as i,canAccessSync as n,resolveIdentityPathViaExistingAncestor as r,canAccess as t};