repl: deprecate REPLServer.prototype.turnOffEditorMode#15136
repl: deprecate REPLServer.prototype.turnOffEditorMode#15136lance wants to merge 4 commits intonodejs:masterfrom lance:repl-remove-code-duplication
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 |
BridgeAR
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
The deprecation must be documented as well in the deprecations.md.
There was a problem hiding this comment.
Yes and deprecations are semver-major.
|
Code updated and deprecation documentation added. Edit: Single CI failure on smartos seems to be unrelated |
doc/api/repl.md
Outdated
There was a problem hiding this comment.
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.
Hmm - I would agree, but previous similar deprecations have been handled in this way.
See:
There was a problem hiding this comment.
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.
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.
@BridgeAR are you suggesting removing this commit entirely? Or just removing the wording from repl.md?
There was a problem hiding this comment.
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