All files / packages/sds-release-manager/src/utils semver.ts

100% Statements 9/9
100% Branches 6/6
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15          16x 16x 16x 44x 44x 44x   5x    
/**
 * Compare dotted numeric version triples (e.g. `0.0.140`).
 * Returns negative if left < right, positive if left > right, 0 if equal.
 */
export function compareSemver(left: string, right: string): number {
  const leftParts = left.split('.').map(Number);
  const rightParts = right.split('.').map(Number);
  for (let index = 0; index < 3; index++) {
    const leftSegment = leftParts[index] ?? 0;
    const rightSegment = rightParts[index] ?? 0;
    if (leftSegment !== rightSegment) return leftSegment - rightSegment;
  }
  return 0;
}