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: remove lib/utils/read-package-name.js #4757

Merged
merged 1 commit into from
Apr 19, 2022
Merged

Conversation

wraithgar
Copy link
Member

@wraithgar wraithgar commented Apr 14, 2022

This code wasn't doing anything special, just dereferencing name from
a packument. There is no need for this to exist.

Most of the tests were able to handle having this go away, except for
npm owner which had to have its tests rewritten to be real, which of
course surfaced bugs along the way of behavior that was incorrectly
being tested. npm owner needs some love to clean up its UX, it throws
or returns inconsistently. I did fix it so that if there is no
package.json in cwd it errored as expected instead of throwing ENOENT
which is what it did before.

@wraithgar wraithgar requested a review from a team as a code owner April 14, 2022 21:00
@wraithgar wraithgar marked this pull request as draft April 14, 2022 21:01
@wraithgar wraithgar changed the title gar/read package name fix: remove lib/utils/read-package-name.js Apr 14, 2022
@wraithgar wraithgar marked this pull request as ready for review April 15, 2022 14:40
@npm-robot
Copy link
Contributor

npm-robot commented Apr 15, 2022

no statistically significant performance changes detected

timing results
app-large clean lock-only cache-only cache-only
peer-deps
modules-only no-lock no-cache no-modules no-clean no-clean
audit
npm@8 49.794 ±1.44 26.601 ±0.02 15.675 ±0.07 17.666 ±0.55 2.719 ±0.00 2.725 ±0.00 2.178 ±0.00 10.315 ±0.01 2.179 ±0.01 3.122 ±0.01
#4757 50.086 ±0.61 26.841 ±0.13 15.892 ±0.10 18.110 ±0.77 2.763 ±0.01 2.768 ±0.01 2.208 ±0.00 10.480 ±0.04 2.221 ±0.02 3.207 ±0.03
app-medium clean lock-only cache-only cache-only
peer-deps
modules-only no-lock no-cache no-modules no-clean no-clean
audit
npm@8 37.804 ±1.84 20.662 ±0.08 11.581 ±0.01 12.678 ±0.11 2.489 ±0.00 2.494 ±0.01 2.191 ±0.02 7.698 ±0.12 2.079 ±0.01 2.875 ±0.13
#4757 36.403 ±2.34 21.001 ±0.12 11.857 ±0.01 12.619 ±0.37 2.543 ±0.05 2.507 ±0.00 2.213 ±0.02 7.752 ±0.04 2.068 ±0.01 2.814 ±0.03

@@ -7,6 +7,7 @@ const pacote = require('pacote')
const pickManifest = require('npm-pick-manifest')
const log = require('../utils/log-shim')
const readPackageName = require('../utils/read-package-name.js')
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like this is used a few other places in this file. Can it be removed from those too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought i got them all. It's very concerning that tests still pass here.

Copy link
Contributor

Choose a reason for hiding this comment

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

also i think the actual util file didn't get deleted, only the test

Copy link
Member Author

Choose a reason for hiding this comment

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

This is why we review. Removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

at least that explains why the tests passed previously 😅

This code wasn't doing anything special, just dereferencing `name` from
a packument.  There is no need for this to exist.

Most of the tests were able to handle having this go away, except for
`npm owner` which had to have its tests rewritten to be real, which of
course surfaced bugs along the way of behavior that was incorrectly
being tested.  `npm owner` needs some love to clean up its UX, it throws
or returns inconsistently.  I did fix it so that if there is no
package.json in cwd it errored as expected instead of throwing `ENOENT`
which is what it did before.
@lukekarrys lukekarrys merged commit 8da28b4 into latest Apr 19, 2022
@lukekarrys lukekarrys deleted the gar/read-package-name branch April 19, 2022 23:30
@ruyadorno ruyadorno mentioned this pull request Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants