installedPeers

tcmts.loader.packages.installedPeers · #af36uelg · term · runs on the server

uses node:fs

The peer dependencies of the installed copy of a pinned module.

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

export function installedPeers(lay: Layout, module: string): Record<string, string> {
  try {
    const pkg = JSON.parse(fs.readFileSync(path.join(lay.cacheDir, "node_modules", npmAlias(module), "package.json"), "utf8")) as { peerDependencies?: Record<string, string> };
    return pkg.peerDependencies ?? {};
  } catch {
    return {};
  }
}

uses

used by