Skip to content

Commit

Permalink
Update Package Reader to Accept Range Versions in Dependencies (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptodev-2s authored Nov 8, 2023
1 parent c41cc8b commit 203b612
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/package-manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ describe('package-manifest', () => {
private: true,
dependencies: {
a: '1.0.0',
b: '^2.0.0',
c: '~4.3.0',
},
};
const validated = {
Expand All @@ -73,6 +75,8 @@ describe('package-manifest', () => {
private: true,
dependencies: {
a: '1.0.0',
b: '^2.0.0',
c: '~4.3.0',
},
peerDependencies: {},
};
Expand All @@ -94,6 +98,8 @@ describe('package-manifest', () => {
private: true,
peerDependencies: {
a: '1.0.0',
b: '^2.0.0',
c: '~4.3.0',
},
};
const validated = {
Expand All @@ -104,6 +110,8 @@ describe('package-manifest', () => {
dependencies: {},
peerDependencies: {
a: '1.0.0',
b: '^2.0.0',
c: '~4.3.0',
},
};
await fs.promises.writeFile(manifestPath, JSON.stringify(unvalidated));
Expand Down
4 changes: 2 additions & 2 deletions src/package-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { isPlainObject } from '@metamask/utils';
import { readJsonObjectFile } from './fs';
import { isTruthyString } from './misc-utils';
import { isValidSemver, SemVer } from './semver';
import { semver, SemVer } from './semver';

export { PackageManifestFieldNames, PackageManifestDependenciesFieldNames };

Expand Down Expand Up @@ -139,7 +139,7 @@ export function readPackageManifestNameField(
function isValidPackageManifestVersionField(
version: unknown,
): version is string {
return isTruthyString(version) && isValidSemver(version);
return isTruthyString(version) && semver.validRange(version) !== null;
}

/**
Expand Down

0 comments on commit 203b612

Please sign in to comment.