projectRoot

tcmts.cli.libraries.projectRoot · #7nzbivxi · term · runs anywhere

The namespace a codebase's own code is in: its one top-level namespace, or none if it has several.

export function projectRoot(paths: string[]): string {
  const tops = new Set(paths.map((p) => p.split(".")[0]!));
  return tops.size === 1 && paths.some((p) => p.includes(".")) ? [...tops][0]! : "";
}

used by