UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

26 lines (25 loc) • 919 B
import { r as isMissingPathError } from "./errno-FR4CRyya.mjs"; import fs from "node:fs"; import fs$1 from "node:fs/promises"; import { hasNodeErrorCode, isNotFoundPathError } from "@openclaw/fs-safe/path"; //#region src/infra/path-existence.ts /** Only definite absence, including a non-directory ancestor, permits an absent verdict. */ function pathMayExistSync(filePath) { try { fs.lstatSync(filePath); return true; } catch (error) { return !isMissingPathError(error); } } /** Inspect links themselves; callers decide whether a non-directory ancestor counts as absent. */ async function lstatIfExists(filePath, missingErrors = "ENOENT_OR_ENOTDIR") { try { return await fs$1.lstat(filePath); } catch (error) { if (missingErrors === "ENOENT" ? hasNodeErrorCode(error, "ENOENT") : isNotFoundPathError(error)) return; throw error; } } //#endregion export { pathMayExistSync as n, lstatIfExists as t };