Files
keycloak_theme/src/bin/tools/readThisNpmPackageVersion.ts
Joseph Garrone af7a45d125 checkpoint
2024-11-02 22:39:03 +01:00

25 lines
600 B
TypeScript

import { getThisCodebaseRootDirPath } from "./getThisCodebaseRootDirPath";
import { assert } from "tsafe/assert";
import * as fs from "fs";
import { join as pathJoin } from "path";
let cache: string | undefined = undefined;
export function readThisNpmPackageVersion(): string {
if (cache !== undefined) {
return cache;
}
const version = JSON.parse(
fs
.readFileSync(pathJoin(getThisCodebaseRootDirPath(), "package.json"))
.toString("utf8")
)["version"];
assert(typeof version === "string");
cache = version;
return version;
}