Skip to content

Commit

Permalink
fix: better support for *
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed Jul 5, 2023
1 parent 437c4e4 commit 1ac69e6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/definitions/checks/checkMinRangeSatisfies.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/definitions/checks/checkPeerDependencies.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/index-node16.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ function checkPeerDependencies(pkg, reportError, type, allowedPeerIn, providedDe
if (version.startsWith('npm:')) {
return;
}
if (version === '*') {
return;
}
const minVersionOfVersion = semver.minVersion(version);
if (!minVersionOfVersion || !semver.satisfies(minVersionOfVersion, range, {
includePrerelease: true
Expand Down Expand Up @@ -328,6 +331,7 @@ function checkMinRangeSatisfies(pkgPathName, pkg, type1 = 'dependencies', type2
}
const reportError = customCreateReportError(`"${type1}" minimum range satisfies "${type2}"`, pkgPathName);
for (const [depName, depRange1] of getEntries(dependencies1)) {
if (depRange1 === '*') continue;
const depRange2 = dependencies2[depName];
if (!depRange2 || !depRange1) continue;
const minDepRange1 = semver.minVersion(depRange1)?.version || depRange1;
Expand Down
2 changes: 1 addition & 1 deletion dist/index-node16.mjs.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/checks/checkMinRangeSatisfies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ describe(checkMinRangeSatisfies.name, () => {
devDependencies: { test1: '^1.1.0' },
},
],
[
'* dependency',
{
dependencies: { test1: '*' },
devDependencies: { test1: '^1.1.0' },
},
],
])('should have no error when %s', (_, pkgContent) => {
checkMinRangeSatisfies(
'path',
Expand Down
2 changes: 2 additions & 0 deletions src/checks/checkMinRangeSatisfies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export function checkMinRangeSatisfies(
);

for (const [depName, depRange1] of getEntries(dependencies1)) {
if (depRange1 === '*') continue;

const depRange2 = dependencies2[depName];
if (!depRange2 || !depRange1) continue;

Expand Down
4 changes: 4 additions & 0 deletions src/checks/checkPeerDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export function checkPeerDependencies(
return;
}

if (version === '*') {
return;
}

const minVersionOfVersion = semver.minVersion(version);
if (
!minVersionOfVersion ||
Expand Down

0 comments on commit 1ac69e6

Please sign in to comment.