-
Notifications
You must be signed in to change notification settings - Fork 30k
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
repl: deprecate REPLServer.prototype.turnOffEditorMode #15136
Conversation
Why not make it a function instead of a method if the goal is code duplication? function turnOnEditorMode(repl) {
repl.editorMode = true;
REPLServer.super_.prototype.setPrompt.call(repl, '');
} |
@benjamingr this was my original intent, but then I noticed that |
Pinging @nodejs/ctc regarding an API addition in a stable module. |
I would definitely prefer this to be a private function. I think a good way to handle it would be to deprecate the current |
OK, it seems there is consensus around keeping this private and not adding to the API. I will modify this PR to make Refs: #7619 |
I'm not 100% sold on deprecating this this API. /cc @Fishrock123 P.S. I could not find any uses of |
@princejwesley I personally prefer a calling syntax like function _turnOnEditorMode(repl) {
// do something with repl
} So that's how I wrote the function. But that doesn't work as far as I know, with function _turnOffEditorMode() {
// `this` is the calling context
} I could modify Either way works for me. |
@refack |
@BridgeAR @princejwesley @refack ping. I hope I have answered your questions. And if not, let me know what specific actions you think I should take. @benjamingr as it is now, with my recent changes, this does not add any API to the |
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.
In general this is the right approach out of my perspective. Having two different kinds of function calls is a bit ugly though and the deprecation must be documented.
lib/repl.js
Outdated
}; | ||
|
||
REPLServer.prototype.turnOffEditorMode = util.deprecate( | ||
_turnOffEditorMode, |
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 think it would be nicer to have _turnOffEditorMode(this);
(or self) instead of _turnOffEditorMode.call(this);
It is weird that turnOn
and turnOff
works differently.
In that case the prototype function would have to be changed to look somewhat like
function () {
_turnOffEditorMode(this);
}
lib/repl.js
Outdated
REPLServer.prototype.turnOffEditorMode = util.deprecate( | ||
_turnOffEditorMode, | ||
'REPLServer.turnOffEditorMode() is deprecated', | ||
'DEP00XX'); |
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.
The deprecation must be documented as well in the deprecations.md
.
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.
Yes and deprecations are semver-major.
Code updated and deprecation documentation added. Edit: Single CI failure on smartos seems to be unrelated
|
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.
LGTM % comment
doc/api/repl.md
Outdated
|
||
An internal method used to turn off editor mode when entering | ||
code in the REPL. | ||
|
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.
Actually I think we do not have to document this at all. This would create bigger confusion than providing benefit.
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.
Hmm - I would agree, but previous similar deprecations have been handled in this way.
See:
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 think documenting this is the opposite of what we actually want to achieve. I do not really read in that comment that we necessarily have to document this either and I would rather only have the deprecation notice that this was never meant to be exposed and that it is now deprecated but no further documentation.
@jasnell what do you think about this?
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.
By the way - the deprecation docs do not cover this part at all. Therefore I think it is safe to remove this.
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.
@BridgeAR are you suggesting removing this commit entirely? Or just removing the wording from repl.md
?
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.
Only the part from the repl.md
.
This needs some LGs due to being semver-major @nodejs/tsc |
Ping @nodejs/tsc PTAL |
@lance would you be so kind and rebase? |
This commit exposes `REPLServer.prototype.turnOnEditorMode()` which handles the necessary internal changes required instead of having them scattered about.
This deprecates the current REPLServer.prototype.turnOffEditorMode
Also, address some concerns from code review.
@BridgeAR kindness applied! :) |
Not happy with the results of that CI. I scanned a couple of the failures just briefly, and they seem unrelated. But it's surprising there are so many red dots. Trying again. |
@lance CI is clean, failures are unrelated (even linter) |
This deprecates the current REPLServer.prototype.turnOffEditorMode and adds a private function for turnOffEditorMode which handles the necessary internal changes required instead of having them scattered about. PR-URL: #15136 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in e416b3e I fixed the merge conflicts while landing. |
This slipped through while landing. Ref: nodejs#15136
This deprecates the current REPLServer.prototype.turnOffEditorMode and adds a private function for turnOffEditorMode which handles the necessary internal changes required instead of having them scattered about. PR-URL: nodejs/node#15136 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This slipped through while landing. PR-URL: #15668 Refs: #15136 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This slipped through while landing. PR-URL: nodejs/node#15668 Refs: nodejs/node#15136 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This commit
exposesdeprecatesREPLServer.prototype.turnOnEditorMode()
which handles the necessary internal changes to enter editor modeREPLServer.prototype.turnOffEditorMode()
in the REPL,instead of having them scattered aboutand consolidates some duplicated code for turning on editor mode as a non-public function.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
repl, doc