Skip to content

Commit 7b7bde8

Browse files
committed
Adds pre support to versions
Changes migration to be from beta2
1 parent 499d99e commit 7b7bde8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin
133133
}
134134
}
135135

136-
if (Versions.compare(previous, Versions.from(7, 3, 0)) !== 1) {
136+
if (Versions.compare(previous, Versions.from(7, 3, 0, 'beta2')) !== 1) {
137137
const oldSection = 'advanced.maxQuickHistory';
138138
const inspection = configuration.inspect(oldSection);
139139
if (inspection !== undefined) {

src/system/version.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export namespace Versions {
55
major: number;
66
minor: number;
77
patch: number;
8+
pre?: string;
89
}
910

1011
export function compare(v1: Version, v2: Version): number {
@@ -17,19 +18,26 @@ export namespace Versions {
1718
if (v1.patch > v2.patch) return 1;
1819
if (v1.patch < v2.patch) return -1;
1920

21+
if (v1.pre === undefined && v2.pre !== undefined) return 1;
22+
if (v1.pre !== undefined && v2.pre === undefined) return -1;
23+
24+
if (v1.pre !== undefined && v2.pre !== undefined) return v1.pre.localeCompare(v2.pre);
25+
2026
return 0;
2127
}
2228

23-
export function from(major: string | number, minor: string | number, patch: string | number): Version {
29+
export function from(major: string | number, minor: string | number, patch: string | number, pre?: string): Version {
2430
return {
2531
major: typeof major === 'string' ? parseInt(major, 10) : major,
2632
minor: typeof minor === 'string' ? parseInt(minor, 10) : minor,
27-
patch: typeof patch === 'string' ? parseInt(patch, 10) : patch
33+
patch: typeof patch === 'string' ? parseInt(patch, 10) : patch,
34+
pre: pre
2835
};
2936
}
3037

3138
export function fromString(version: string): Version {
32-
const [major, minor, patch] = version.split('.');
33-
return from(major, minor, patch);
39+
const [ver, pre] = version.split('-');
40+
const [major, minor, patch] = ver.split('.');
41+
return from(major, minor, patch, pre);
3442
}
3543
}

0 commit comments

Comments
 (0)