mirror of
https://github.com/portainer/portainer.git
synced 2025-07-31 11:19:40 +02:00
23 lines
469 B
TypeScript
23 lines
469 B
TypeScript
import semverCompare from 'semver-compare';
|
|
|
|
export function compareVersion(
|
|
currentVersion: string,
|
|
version = '',
|
|
bigger = false
|
|
) {
|
|
if (!currentVersion) {
|
|
return true;
|
|
}
|
|
|
|
// if supplied version is not a string, e.g develop
|
|
if (!version.includes('.')) {
|
|
return true;
|
|
}
|
|
|
|
if (bigger) {
|
|
return semverCompare(currentVersion, version) > 0;
|
|
}
|
|
|
|
// env version is less than the supplied
|
|
return semverCompare(currentVersion, version) < 0;
|
|
}
|