From af7d9a373df76cc023f5a7b9af9b5f2f4ee342ed Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 21 Jan 2019 01:08:22 +0100 Subject: [PATCH 1/2] repl: deprecate REPLServer.rli This is only a reference to the instance and should not be used. --- doc/api/deprecations.md | 14 +++++++++++++- lib/repl.js | 11 +++++++++-- test/parallel/test-repl-options.js | 6 ++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 169b5a51315465..e66cd2228c9cc5 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2321,7 +2321,6 @@ Type: Runtime Please use `Server.prototype.setSecureContext()` instead. - ### DEP0123: setting the TLS ServerName to an IP address + +Type: Runtime + +This property is just a reference to the instance itself. + [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size [`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array diff --git a/lib/repl.js b/lib/repl.js index 1f89f43c241488..ab19884c8821d6 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -176,8 +176,15 @@ function REPLServer(prompt, // Context id for use with the inspector protocol. self[kContextId] = undefined; - // Just for backwards compat, see github.com/joyent/node/pull/7127 - self.rli = this; + let rli = self; + Object.defineProperty(self, 'rli', { + get: util.deprecate(() => rli, + 'REPLServer.rli is deprecated', 'DEP0XXX'), + set: util.deprecate((val) => rli = val, + 'REPLServer.rli is deprecated', 'DEP0XXX'), + enumerable: true, + configurable: true + }); const savedRegExMatches = ['', '', '', '', '', '', '', '', '', '']; const sep = '\u0000\u0000\u0000'; diff --git a/test/parallel/test-repl-options.js b/test/parallel/test-repl-options.js index 8d9f8e5b0703c4..72e39c441358da 100644 --- a/test/parallel/test-repl-options.js +++ b/test/parallel/test-repl-options.js @@ -25,6 +25,12 @@ const ArrayStream = require('../common/arraystream'); const assert = require('assert'); const repl = require('repl'); +common.expectWarning({ + DeprecationWarning: { + DEP0XXX: 'REPLServer.rli is deprecated' + } +}); + // Create a dummy stream that does nothing const stream = new ArrayStream(); From ccd936b9c6dcead9e0b5ce2d54a04716d8cf557f Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 28 Feb 2019 18:03:33 +0100 Subject: [PATCH 2/2] fixup: address nits --- doc/api/deprecations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index e66cd2228c9cc5..7d69cb44ecc7b1 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -2336,7 +2336,7 @@ Setting the TLS ServerName to an IP address is not permitted by [RFC 6066][]. This will be ignored in a future version. -### DEP0XXX: using REPLServer#rli +### DEP0XXX: using REPLServer.rli