Skip to content

Commit

Permalink
ignore or-chains, fixes #43
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed May 25, 2020
1 parent 9e8eab6 commit 9f34211
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion fixtures/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"updates": "file:."
},
"peerDependencies": {
"@babel/preset-env": "~6.0.0"
"@babel/preset-env": "~6.0.0",
"svgstore": "^1.0.0 || ^2.0.0"
}
}
12 changes: 6 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ function makeTest(args, expected) {

// Parse results, with custom validation for the dynamic "age" property
for (const dependencyType of dependencyTypes) {
for (const [dependencyName, data] of Object.entries(expected[dependencyType] || {})) {
for (const [key, value] of Object.entries(data || {})) {
const resultValue = results[dependencyType][dependencyName][key];
for (const [dependencyName, actual] of Object.entries(results[dependencyType] || {})) {
for (const [key, actualValue] of Object.entries(actual || {})) {
const expectedValue = expected[dependencyType][dependencyName][key];
if (key === "age") {
expect(resultValue).toBeInstanceOf(String);
expect(resultValue.length > 0).toBeTruthy();
expect(typeof actualValue).toEqual("string");
expect(actualValue.length > 0).toBeTruthy();
} else {
expect(resultValue).toEqual(value);
expect(expectedValue).toEqual(actualValue);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@ function findVersion(data, versions, {range, semvers, usePre, useRel, useGreates
}

function findNewVersion(data, opts) {
if (opts.range === "*") return "*";
if (opts.range === "*") return null; // ignore wildcard
if (opts.range.includes("||")) return null; // ignore or-chains
const versions = Object.keys(data.versions).filter(version => semver.valid(version));
const version = findVersion(data, versions, opts);

Expand Down

0 comments on commit 9f34211

Please sign in to comment.