provideTool
uses node:path
A tool tcm provides: the one it ships, or installed in the cache as toolModule says (there already, if it was
installed with other packages, as a test runner's are).
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { toolModule } from "#codebase/tcmts/cli/lint"; import { compatRange } from "#codebase/tcmts/core/semver"; import { ensureExternals, npmAlias, parseModule, shippedPackage } from "#codebase/tcmts/loader/packages"; import path from "node:path"; export function provideTool( cb: Codebase, name: string, ): { module: string; dir: string; version: string } { const module = toolModule(cb, name); if (!module) { const own = shippedPackage(name)!; return { module: `npm:${name}@${compatRange(own.version)}`, dir: own.dir, version: own.version, }; } ensureExternals(cb.lay, [{ module, subpath: "", export: "*" }]); return { module, dir: path.join(cb.lay.cacheDir, "node_modules", npmAlias(module)), version: cb.store.lockedVersion(name, parseModule(module).version)!, }; }
uses
- tcmts.cli.codebase.Codebase
- tcmts.cli.lint.toolModule
- tcmts.core.semver.compatRange
- tcmts.loader.packages.ensureExternals
- tcmts.loader.packages.npmAlias
- tcmts.loader.packages.parseModule
- tcmts.loader.packages.shippedPackage