-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
chore(refactor): refactor exit handler and tests #3482
Conversation
This is done, with a more meaningful comment explaining why it's in there |
6ba68c9
to
44e234d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm a big fan of these pull requests that delete a bunch of misdirection and just generally unnecessary code
left one question, but this all looks good as far as i can see. much simpler and much more clear 👍
lib/base-command.js
Outdated
@@ -75,7 +75,6 @@ class BaseCommand { | |||
} | |||
|
|||
async setWorkspaces (filters) { | |||
// TODO npm guards workspaces/global mode so we should use this.npm.prefix? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this TODO not something we still need to do? is this an answered question already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the entire approach to npm.prefix vs npm.localPrefix etc needs addressing and I'd rather leave these comments in until we actually properly audit and review how we're using those.
this.started = Date.now() | ||
this.command = null | ||
this.commands = proxyCmds | ||
this.timings = timings | ||
this.timers = timers | ||
this.perfStart() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a great intermediate step to avoid the singleton issue 🎉
process.on('exit', code => { | ||
// process.emit is synchronous, so the timeEnd handler will run before the | ||
// unfinished timer check below |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 thank you for calling this out, it's a super nice reminder!
44e234d
to
f828c5f
Compare
rebasing fixed the conflicts w/o having to change anything. PHEW |
* npm mock logger writes to npm.log.record too now * No more extra process.exit from within the process `exit` event handle. * No more `exit()` function. Logic is rolled up into the exit handler. * Now there is only an exit handler and an exit event listener. `lib/utils/perf.js` was rolled up into npm.js itself. Unfortunately the tests were written in such a way that any further refactoring of the exit handler was going to require also rewriting the tests. Fortunately NOW the tests are interacting with the exit handler in a way that shouldn't require them to be rewritten AGAIN if we change the internals of the exit handler. PR-URL: #3482 Credit: @wraithgar Close: #3482 Reviewed-by: @nlf
f828c5f
to
efc4313
Compare
exit
event handle.exit()
function. Logic is rolled up into the exit handler.lib/utils/perf.js
was rolled up into npm.js itself.Unfortunately the tests were written in such a way that any further
refactoring of the exit handler was going to require also rewriting the
tests. Fortunately NOW the tests are interacting with the exit handler
in a way that shouldn't require them to be rewritten AGAIN if we change
the internals of the exit handler.
Needs #3479 to land first