-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/versions filter not function #233
Conversation
alo3y
commented
Oct 18, 2021
- Fixed verifyDeps when npm view returns a string on packages with a single version
- Added tests
Codecov Report
@@ Coverage Diff @@
## develop #233 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 79 80 +1
Branches 13 14 +1
=========================================
+ Hits 79 80 +1
Continue to review full report at Codecov.
|
lib/index.js
Outdated
@@ -46,11 +46,12 @@ async function getLatestTag(name) { | |||
async function getLatestVersion(name, wanted) { | |||
const versions = await getLatestVersions(name); | |||
const latest = await getLatestTag(name); | |||
let applicableVersions = versions.filter((i) => semver.satisfies(i, wanted)); | |||
const versionsArray = typeof versions === 'string' ? [versions] : versions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do this check/conversion inside getLatestVersions function. It's pretty crazy that it returns different formats.
lib/index.test.js
Outdated
@@ -425,6 +425,23 @@ describe('lib/index', () => { | |||
'NPM package name: "bad name Dependency" is invalid. name can only contain URL-friendly characters' | |||
); | |||
}); | |||
|
|||
test('should verify deps when npm view returns a string', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's clarify this description:
"should verify dependencies when npm module has only one version available, npm view returns string instead of array"
lib/index.test.js
Outdated
mockExports.dependencies = { foo1: '1.1.1' }; | ||
mockExports.devDependencies = {}; | ||
|
||
mockExecAsync.mockImplementationOnce(() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it a one line statement, no need to take up space here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, just a few edits 🎉