defaultMount

tcmts.cli.libraries.defaultMount · #aau2kfgd · term · runs anywhere

Where a library is mounted unless it's said: lib.<name> in the project's root namespace (tcmts.lib.geo). The libraries mounted already (mounts), their record and the trust list (lib.trust) aren't the project's code: a codebase holding only lib.react mounts the next at lib.server.

import { projectRoot, RECORD, within } from "#codebase/tcmts/cli/libraries";

export function defaultMount(paths: string[], name: string, mounts: string[] = []): string {
  const root = projectRoot(
    paths.filter(
      (p) =>
        p.slice(p.lastIndexOf(".") + 1) !== RECORD &&
        !/(^|\.)lib\.trust$/.test(p) &&
        !mounts.some((m) => within(p, m)),
    ),
  );
  return `${root ? `${root}.` : ""}lib.${name}`;
}

uses

used by