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

fix: cordova-fetch with npm@7 #91

merged 4 commits into from Jan 26, 2021

fix: cordova-fetch with npm@7 #91

merged 4 commits into from Jan 26, 2021


Copy link

@raphinesse raphinesse commented Oct 15, 2020

Motivation and Context



Instead of parsing the installed package's name out of the output of npm install <spec> (which does not work anymore with npm@7) we now do the following:

  • First try to determine the name from the spec using npm-package-arg. This is very cheap.
  • If that fails, get out the big guns and fetch a full manifest using pacote.

Both of these libraries are also used by npm itself.

Fetching the manifest can be expensive (e.g. for a git repo spec). But since pacote and npm share a cache and we always install a package after fetching a manifest anyway, the additional cost should be negligible in our case. Measuring the execution time of this repo's tests on my machine seems to confirm this: the time is roughly the same before and after this PR.

Furthermore this PR makes some adjustments to test expectations to handle minor behavior changes in npm@7.



@raphinesse raphinesse added the bug label Oct 15, 2020
@raphinesse raphinesse added this to the 3.0.1 milestone Oct 15, 2020
Copy link

codecov-io commented Oct 15, 2020

Codecov Report

Merging #91 (dace3fc) into master (1d96eae) will increase coverage by 0.90%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #91      +/-   ##
+ Coverage   92.42%   93.33%   +0.90%     
  Files           1        1              
  Lines          66       60       -6     
- Hits           61       56       -5     
+ Misses          5        4       -1     
Impacted Files Coverage Δ
index.js 93.33% <100.00%> (+0.90%) ⬆️

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 1d96eae...dace3fc. Read the comment docs.

This addresses the following changes in behavior.

Saved GitHub URL format in package.json:
- npm 6: git+
- npm 7: github:apache/cordova-android#4.1.x

Empty devDependencies format in package.json:
- npm 6: `{}`
- npm 7: `undefined`
@raphinesse raphinesse changed the title fix: cordova-fetch w/ npm@7 fix: cordova-fetch with npm@7 Oct 16, 2020
Copy link

@breautek breautek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants