lockAtLeast

tcmts.loader.packages.lockAtLeast · #krp6hxba · term · runs anywhere

Raise the lock for name within range to at least version: code was checked against it, and within a compatible range a newer version only adds (semver). Returns the version before, if it changed.

import { compareVersions } from "#codebase/tcmts/core/semver";
import type { Layout } from "#codebase/tcmts/loader";
import { lockOf } from "#codebase/tcmts/loader/packages";

export function lockAtLeast(lay: Layout, name: string, range: string, version: string): string | undefined {
  const lock = lockOf(lay);
  const was = lock.get(name, range);
  if (was && compareVersions(version, was) <= 0) return undefined;
  lock.set(name, range, version);
  return was;
}

uses

used by