openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
26 lines (25 loc) • 1.19 kB
JavaScript
import "./fs-safe-defaults-DGE52WTl.js";
import fs from "node:fs";
import path from "node:path";
import { resolvePathViaExistingAncestorSync, resolveRootPath, resolveRootPathSync } from "@openclaw/fs-safe/advanced";
import { safeRealpathSync, safeRealpathSync as safeRealpathSync$1 } from "@openclaw/fs-safe/path";
//#region src/infra/boundary-path.ts
/** Returns a canonical path when resolvable, otherwise an absolute lexical path. */
function resolveRealpathOrAbsolute(value) {
return safeRealpathSync(value) ?? path.resolve(value);
}
function resolveIdentityPathViaExistingAncestorSync(targetPath) {
const fallback = path.resolve(targetPath);
const missingSegments = [];
let cursor = fallback;
while (true) try {
return path.join(fs.realpathSync.native(cursor), ...missingSegments.toReversed());
} catch {
const parent = path.dirname(cursor);
if (parent === cursor) return fallback;
missingSegments.push(path.basename(cursor));
cursor = parent;
}
}
//#endregion
export { resolveRootPathSync as a, resolveRootPath as i, resolvePathViaExistingAncestorSync as n, safeRealpathSync$1 as o, resolveRealpathOrAbsolute as r, resolveIdentityPathViaExistingAncestorSync as t };