openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
24 lines (23 loc) • 1.24 kB
JavaScript
import { o as normalizeNullableString } from "./string-coerce-mnp54Vah.js";
import { o as tryReadJson } from "./json-files-2umMHm0W.js";
import path from "node:path";
//#region src/infra/package-json.ts
/** Reads package.json as a loose object, returning null for missing or invalid manifests. */
async function readPackageJson(root) {
const parsed = await tryReadJson(path.join(root, "package.json"));
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
}
/** Reads and trims the package version string, returning null for blank or non-string values. */
async function readPackageVersion(root) {
return normalizeNullableString((await readPackageJson(root))?.version);
}
/** Reads and trims the package name string, returning null for blank or non-string values. */
async function readPackageName(root) {
return normalizeNullableString((await readPackageJson(root))?.name);
}
/** Reads and trims the packageManager spec, returning null for blank or non-string values. */
async function readPackageManagerSpec(root) {
return normalizeNullableString((await readPackageJson(root))?.packageManager);
}
//#endregion
export { readPackageName as n, readPackageVersion as r, readPackageManagerSpec as t };