owns

tcmts.cli.manifests.owns · #p7fkyham · term · runs anywhere

Whether a name is the package's own: in its namespace, not in a package nested in it, not its manifest, a test or tool config.

import { isManifestPath, within } from "#codebase/tcmts/cli/manifests";
import type { Pkg } from "#codebase/tcmts/cli/manifests";
import { isTestPath } from "#codebase/tcmts/cli/testing";

export function owns(pkg: Pkg, all: Pkg[], p: string): boolean {
  if (!within(pkg.namespace, p) || isManifestPath(p) || isTestPath(p) || p.endsWith("lint.config") || p.endsWith("fmt.config")) return false;
  return !all.some((o) => o !== pkg && o.namespace.length > pkg.namespace.length && within(pkg.namespace, o.namespace) && within(o.namespace, p));
}

uses

used by