mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Fix version ordering
This commit is contained in:
parent
30ebebd7e8
commit
331734f7ee
2 changed files with 13 additions and 2 deletions
7
dist/index.js
vendored
7
dist/index.js
vendored
|
|
@ -3471,7 +3471,7 @@ var NpmModuleVersion;
|
||||||
*/
|
*/
|
||||||
function compare(v1, v2) {
|
function compare(v1, v2) {
|
||||||
const sign = (diff) => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
|
const sign = (diff) => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
|
||||||
const noUndefined = (n) => n !== null && n !== void 0 ? n : -1;
|
const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity;
|
||||||
for (const level of ["major", "minor", "patch", "betaPreRelease"]) {
|
for (const level of ["major", "minor", "patch", "betaPreRelease"]) {
|
||||||
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
||||||
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
|
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
|
||||||
|
|
@ -3480,6 +3480,11 @@ var NpmModuleVersion;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
NpmModuleVersion.compare = compare;
|
NpmModuleVersion.compare = compare;
|
||||||
|
/*
|
||||||
|
console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0")) === -1 )
|
||||||
|
console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0-beta.4")) === -1 )
|
||||||
|
console.log(compare(parse("3.0.0-beta.3"), parse("4.0.0")) === -1 )
|
||||||
|
*/
|
||||||
function bumpType(params) {
|
function bumpType(params) {
|
||||||
const versionAhead = parse(params.versionAheadStr);
|
const versionAhead = parse(params.versionAheadStr);
|
||||||
const versionBehind = parse(params.versionBehindStr);
|
const versionBehind = parse(params.versionBehindStr);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ export namespace NpmModuleVersion {
|
||||||
export function compare(v1: NpmModuleVersion, v2: NpmModuleVersion): -1 | 0 | 1 {
|
export function compare(v1: NpmModuleVersion, v2: NpmModuleVersion): -1 | 0 | 1 {
|
||||||
|
|
||||||
const sign = (diff: number): -1 | 0 | 1 => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
|
const sign = (diff: number): -1 | 0 | 1 => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
|
||||||
const noUndefined= (n: number | undefined)=> n ?? -1;
|
const noUndefined= (n: number | undefined)=> n ?? Infinity;
|
||||||
|
|
||||||
for (const level of ["major", "minor", "patch", "betaPreRelease"] as const) {
|
for (const level of ["major", "minor", "patch", "betaPreRelease"] as const) {
|
||||||
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
||||||
|
|
@ -59,6 +59,12 @@ export namespace NpmModuleVersion {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0")) === -1 )
|
||||||
|
console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0-beta.4")) === -1 )
|
||||||
|
console.log(compare(parse("3.0.0-beta.3"), parse("4.0.0")) === -1 )
|
||||||
|
*/
|
||||||
|
|
||||||
export function bumpType(
|
export function bumpType(
|
||||||
params: {
|
params: {
|
||||||
versionBehindStr: string;
|
versionBehindStr: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue