-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: make REPLServer.bufferedCommand private #13687
Conversation
lib/repl.js
Outdated
self.lines.level = []; | ||
|
||
self.clearBufferedCommand = function clearBufferedCommand() { |
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.
IMHO it would be better to add clearBufferedCommand
to REPLServer.prototype
.
About Object.defineProperty(this, 'bufferedCommand'
I'm not sure since that will change the .hasOwnProperty('bufferedCommand')
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.
Does this function need to be exposed at all? Would it work to create a function in this file that has the symbol in scope and takes the REPL as an argument?
lib/repl.js
Outdated
@@ -72,6 +72,7 @@ for (var n = 0; n < GLOBAL_OBJECT_PROPERTIES.length; n++) { | |||
GLOBAL_OBJECT_PROPERTY_MAP[GLOBAL_OBJECT_PROPERTIES[n]] = | |||
GLOBAL_OBJECT_PROPERTIES[n]; | |||
} | |||
const BUFFERED_COMMAND = Symbol('bufferedCommand'); |
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.
Nit: in general kBufferedCommandSymbol
is prefered to ALL_CAPS.
doc/api/repl.md
Outdated
@@ -375,6 +375,16 @@ The `replServer.displayPrompt` method is primarily intended to be called from | |||
within the action function for commands registered using the | |||
`replServer.defineCommand()` method. | |||
|
|||
### replServer.clearBufferedCommand() | |||
<!-- YAML | |||
added: v8.1.0 |
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.
Should this probably be REPLACEME till landing? Anyway, even 8.1.1 has not this fix.
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. I wasn't sure what to put here (and didn't realize 8.1.1 was released yesterday).
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 am not sure about rules here. Maybe it is usually replaced on backporting from master to current?
Added some comments. |
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.
Do you foresee this being something that is needed at all outside of core? Also, I'm not sure that we can just remove bufferedCommand
with no notice.
doc/api/repl.md
Outdated
--> | ||
|
||
The `replServer.clearBufferedComand()` method clears any command that has been | ||
buffered but not yet executed.This method is primarily intended to be |
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.
Space after the period please.
lib/repl.js
Outdated
self.lines.level = []; | ||
|
||
self.clearBufferedCommand = function clearBufferedCommand() { |
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.
Does this function need to be exposed at all? Would it work to create a function in this file that has the symbol in scope and takes the REPL as an argument?
@cjihrig I really only see 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.
LGTM if this isn't being used.
lib/repl.js
Outdated
'REPLServer.bufferedCommand is deprecated'), | ||
set: util.deprecate((val) => self[kBufferedCommandSymbol] = val, | ||
'REPLServer.bufferedCommand is deprecated') | ||
}); |
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.
add enumerable: true
here.
lib/repl.js
Outdated
get: util.deprecate(() => self[kBufferedCommandSymbol], | ||
'REPLServer.bufferedCommand is deprecated'), | ||
set: util.deprecate((val) => self[kBufferedCommandSymbol] = val, | ||
'REPLServer.bufferedCommand is deprecated') |
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 would need an assigned deprecation code. See doc/api/deprecations.md
.
Before this lands, make the code DEP00XX
and whom ever does the landing would assign the actual code.
The code would be passed in as the third argument for the util.deprecate()
method.
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.
Needs a bit more work. Left a couple comments.
@jasnell thanks - I've added a temporary deprecation code to |
Yes, an entry should be added to |
CI: https://ci.nodejs.org/job/node-test-pull-request/8741/ @jasnell documentation bits added. |
Hmnm feebsd test failed with
which seems unrelated. |
'nother CI https://ci.nodejs.org/job/node-test-commit/10701/ @jasnell look ok to you? |
I've cleared my review. I'd like to get more input from @nodejs/ctc about whether this is something we definitely want to do. |
ping @ChALkeR ... any way to get a usage analysis |
Awaiting CTC review @nodejs/ctc |
@Trott any movement on this from @nodjs/ctc? |
@lance Can you rebase to get rid of conflicts? (I'm guessing it's all white-space stuff based on new stricter indentation linting. Be sure to run |
Needs one more CTC approval. Pinging some CTC folks who have several commits modifying |
https://github.com/search?l=JavaScript&p=2&q=bufferedCommand&type=Code&utf8=%E2%9C%93 has some real world use cases for this currently. Are we sure that we can justify this breaking change? I'm on the fence |
Relates to #12686 The `REPLServer.bufferedCommand` property was undocumented, except for its usage appearing, unexplained, in an example for `REPLServer.defineCommand`. This commit deprecates that property, privatizes it, and adds a `REPLServer.clearBufferedCommand()` function that will clear the buffer.
Change to kBufferedCommandSymbol instead of BUFFERED_COMMAND. Made `clearBufferedCommand` exist on `REPLServer.prototype`. Minor typo corrections.
and make REPLServer.bufferedCommand enumerable
@evanlucas there are a lot of results returned from that query, but the vast majority of them are for
The first case is covered by the addition of I tried to figure out a way to eliminate |
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.
Given the usage data and that its only deprecation at this point it seems reasonable to me.
Landed in f037cbf |
@lance I un-landed this PR because the |
Re-landed in 2ca9f94 I realized I made the same mistake a couple of days ago, maybe that was a bit confusing … sorry! |
The `REPLServer.bufferedCommand` property was undocumented, except for its usage appearing, unexplained, in an example for `REPLServer.defineCommand`. This commit deprecates that property, privatizes it, and adds a `REPLServer.clearBufferedCommand()` function that will clear the buffer. PR-URL: #13687 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: James Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Refs: #12686
@addaleax I realized my mistake after I walked away from my computer today. Thanks for fixing it up. |
The
REPLServer.bufferedCommand
property was undocumented, exceptfor its usage appearing, unexplained, in an example for
REPLServer.defineCommand
. This commit deprecates that property,privatizes it, and adds a
REPLServer.clearBufferedCommand()
function that will clear the buffer.
Refs: #12686
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
repl, doc