chore: Order of operations for the and and or

This commit is contained in:
BluJ
2022-07-15 13:38:29 -06:00
parent bd780db931
commit 59a827160a
2 changed files with 14 additions and 3 deletions

View File

@@ -143,12 +143,12 @@ export class Checker {
return range
}
range = range.trim();
if (range.indexOf('&&') !== -1) {
return rangeAnd(...range.split('&&').map(x => Checker.parse(x)));
}
if (range.indexOf('||') !== -1) {
return rangeOr(...range.split('||').map(x => Checker.parse(x)));
}
if (range.indexOf('&&') !== -1) {
return rangeAnd(...range.split('&&').map(x => Checker.parse(x)));
}
if (range === '*') return new Checker((version) => {
EmVar.from(version)
return true

View File

@@ -226,4 +226,15 @@ test(">1 && =1.2 || =2", () => {
expect(checker.check("2")).toBe(true);
expect(checker.check("3")).toBe(false);
})
test("&& before || order of operationns: <1.5 && >1 || >1.5 && <3", () => {
const checker = rangeOf("<1.5 && >1 || >1.5 && <3");
expect(checker.check("1.1")).toBe(true);
expect(checker.check("2")).toBe(true);
expect(checker.check("1.5")).toBe(false);
expect(checker.check("1")).toBe(false);
expect(checker.check("3")).toBe(false);
})