assetName

tcmts.cli.mirror.assetName · #o4r5q3yq · term · runs on the server

uses node:path

A file's name in a mirror's codebase: its directory's namespace (as for code), and its own name.

import { dirSegment, fileLeaf } from "#codebase/tcmts/cli/files";
import { joinName } from "#codebase/tcmts/cli/mirror";
import path from "node:path";

export function assetName(root: string, into: string, file: string): string {
  const dirs = path.relative(root, path.dirname(file)).split(path.sep).filter((d) => d && d !== "src").map(dirSegment);
  return joinName(into, ...dirs, fileLeaf(file));
}

uses

used by