joelspadin-garmin / vscode-private-extension-manager

Private extension manager for Visual Studio Code
103 stars 22 forks source link

String comparison of version numbers #63

Closed hondzik closed 2 years ago

hondzik commented 2 years ago

Hi, the plugin recommends me to downgrade from 0.1.10 ->0.1.9. The problem is that the version is compared as a string:

public get isUpdateAvailable(): boolean {
    return !!this.installedVersion && this.version > this.installedVersion;
}

Maybe you should use something like the following function (not tested) to pad all numeric pieces of version string to 3 chars:

function comparableSemanticVersion(version: string): string {
    return version.split("-").map((mainPart: string) => {
        return mainPart.split(".").map((part: string) => {
            return Number.isNaN(part) ? part : ("000" + part).substr(-3);
        }).join(".");
    }).join("-");
}
joelspadin-garmin commented 2 years ago

Fixed in #59