Fix: use switch for version compare
This commit is contained in:
parent
90be1dae25
commit
08c7004123
|
@ -107,13 +107,16 @@ var updater = {
|
||||||
const json = usercss.buildMeta(text);
|
const json = usercss.buildMeta(text);
|
||||||
const {usercssData: {version}} = style;
|
const {usercssData: {version}} = style;
|
||||||
const {usercssData: {version: newVersion}} = json;
|
const {usercssData: {version: newVersion}} = json;
|
||||||
// re-install is invalid in a soft upgrade
|
switch (Math.sign(semverCompare(version, newVersion))) {
|
||||||
if (semverCompare(version, newVersion) === 0 && !ignoreDigest) {
|
case 0:
|
||||||
return Promise.reject(updater.SAME_VERSION);
|
// re-install is invalid in a soft upgrade
|
||||||
}
|
if (!ignoreDigest) {
|
||||||
// downgrade is always invalid
|
return Promise.reject(updater.SAME_VERSION);
|
||||||
if (semverCompare(version, newVersion) > 0) {
|
}
|
||||||
return Promise.reject(updater.ERROR_VERSION);
|
break;
|
||||||
|
case 1:
|
||||||
|
// downgrade is always invalid
|
||||||
|
return Promise.reject(updater.ERROR_VERSION);
|
||||||
}
|
}
|
||||||
return usercss.buildCode(json);
|
return usercss.buildCode(json);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user