Skip to content
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

Merged
merged 6 commits into from
Oct 20, 2021

Conversation

alo3y
Copy link
Collaborator

@alo3y alo3y commented Oct 18, 2021

  • Fixed verifyDeps when npm view returns a string on packages with a single version
  • Added tests

@codecov
Copy link

codecov bot commented Oct 18, 2021

Codecov Report

Merging #233 (6c2b1b2) into develop (b8b0396) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 6c2b1b2 differs from pull request most recent head 05a0ee5. Consider uploading reports for the commit 05a0ee5 to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##           develop      #233   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           79        80    +1     
  Branches        13        14    +1     
=========================================
+ Hits            79        80    +1     
Impacted Files Coverage Δ
lib/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8b0396...05a0ee5. Read the comment docs.

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;
Copy link
Contributor

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.

@@ -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 () => {
Copy link
Contributor

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"

mockExports.dependencies = { foo1: '1.1.1' };
mockExports.devDependencies = {};

mockExecAsync.mockImplementationOnce(() =>
Copy link
Contributor

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.

Copy link
Contributor

@jennyEckstein jennyEckstein left a 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 🎉

@jennyEckstein jennyEckstein merged commit bac7788 into develop Oct 20, 2021
@jennyEckstein jennyEckstein deleted the bugfix/versions-filter-not-function branch October 20, 2021 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants