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(npm) pass npm context everywhere #2772

Merged
merged 1 commit into from Mar 4, 2021
Merged

Conversation

wraithgar
Copy link
Member

@wraithgar wraithgar commented Feb 24, 2021

Instead of files randomly requiring the npm singleton, we pass it where it needs to go so that tests don't need to do so much require mocking everywhere.

Instead of continuing down the path of "Just add a function that wraps another function and adds something new to its context," commands are now proper objects.

Usage output is more correct now, that bugfix had to be in here to get things to work.
open-url had a bug where it was never handling its happy-path callback. That bug went away due to refactoring.
Tests were also added that were missing for install-ci-test and install-test.
Other minor bugfixes like how open-url was not ever handling its happy-path callback had to be fixed.

We are going to have to find a better solution for coverage on the usage and completion functions, when they are accessed through npm.commands.x they do not count for coverage, and that is the only way we should ultimately be trying to access them once we have proper tests.

Fixes: npm/statusboard#124

@wraithgar
Copy link
Member Author

This is built off of #2759 but that one should be long since landed by the time this is done.

@wraithgar wraithgar force-pushed the gar/npm-state branch 3 times, most recently from b879719 to 333d704 Compare February 25, 2021 15:48
lib/access.js Outdated Show resolved Hide resolved
lib/access.js Show resolved Hide resolved

if (!cmd)
throw UsageError('Subcommand is required.')
exec (args, cb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like you're heading in this direction already, but pretty please can we ditch the callbacks entirely? 😆 I'd love to see this.access just be this.exec(), and have npm know how to handle that.

Copy link
Member Author

Choose a reason for hiding this comment

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

That change was left out of this PR because of the amount of testing changes it would require. This PR is mostly code change, with minimal test changes.

Making this function async would be a minimal code change, and a larger test change. It'd be much easier than THIS PR, but still needs to be its own thing.

@wraithgar wraithgar force-pushed the gar/npm-state branch 15 times, most recently from 00ccefd to 876a231 Compare February 27, 2021 04:57
@wraithgar wraithgar force-pushed the gar/npm-state branch 3 times, most recently from 7dcc94f to 5bd0d30 Compare February 28, 2021 04:13
@wraithgar wraithgar marked this pull request as ready for review February 28, 2021 04:17
@wraithgar wraithgar requested a review from a team as a code owner February 28, 2021 04:17
@wraithgar wraithgar force-pushed the gar/npm-state branch 2 times, most recently from c3b9d27 to cbea9bc Compare February 28, 2021 04:32
This was referenced Mar 12, 2021
@wraithgar wraithgar deleted the gar/npm-state branch November 2, 2021 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: next These items should be addressed in the next release Release 7.x work is associated with a specific npm 7 release semver:patch semver patch level for changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor lib/utils/open-url.js
4 participants