installedVersion

tcmts.loader.packages.installedVersion · #rvva3pmj · term · runs on the server

uses node:fs

import type { Layout } from "#codebase/tcmts/loader";
import fs from "node:fs";
import path from "node:path";

export const installedVersion = (lay: Layout, alias: string) => {
  try {
    return (JSON.parse(fs.readFileSync(path.join(lay.cacheDir, "node_modules", alias, "package.json"), "utf8")) as { version: string }).version;
  } catch {
    return undefined;
  }
}

uses

used by