Uh oh!
There was an error while loading. Please reload this page.
fix(npm) pass npm context everywhere - #2772
Conversation
wraithgar
commented
Feb 24, 2021
This is built off of #2759 but that one should be long since landed by the time this is done. |
b879719 to
333d704CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| if (!cmd) | ||
| throw UsageError('Subcommand is required.') | ||
| exec (args, cb) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
00ccefd to
876a231Compare7dcc94f to
5bd0d30Comparec3b9d27 to
cbea9bcCompare
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.xthey 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