Skip to content

Commit 5843058

Browse files
committed
repl: deprecate REPLServer.rli
This is only a reference to the instance and should not be used. PR-URL: #26260 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8bb3092 commit 5843058

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

doc/api/deprecations.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -2321,7 +2321,6 @@ Type: Runtime
23212321
23222322
Please use `Server.prototype.setSecureContext()` instead.
23232323
2324-
23252324
<a id="DEP0123"></a>
23262325
### DEP0123: setting the TLS ServerName to an IP address
23272326
<!-- YAML
@@ -2336,6 +2335,19 @@ Type: Runtime
23362335
Setting the TLS ServerName to an IP address is not permitted by
23372336
[RFC 6066][]. This will be ignored in a future version.
23382337
2338+
<a id="DEP0XXX"></a>
2339+
### DEP0XXX: using REPLServer.rli
2340+
<!-- YAML
2341+
changes:
2342+
- version: REPLACEME
2343+
pr-url: https://github.com/nodejs/node/pull/26260
2344+
description: Runtime deprecation.
2345+
-->
2346+
2347+
Type: Runtime
2348+
2349+
This property is a reference to the instance itself.
2350+
23392351
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
23402352
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
23412353
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array

lib/repl.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,15 @@ function REPLServer(prompt,
176176
// Context id for use with the inspector protocol.
177177
self[kContextId] = undefined;
178178

179-
// Just for backwards compat, see github.com/joyent/node/pull/7127
180-
self.rli = this;
179+
let rli = self;
180+
Object.defineProperty(self, 'rli', {
181+
get: util.deprecate(() => rli,
182+
'REPLServer.rli is deprecated', 'DEP0XXX'),
183+
set: util.deprecate((val) => rli = val,
184+
'REPLServer.rli is deprecated', 'DEP0XXX'),
185+
enumerable: true,
186+
configurable: true
187+
});
181188

182189
const savedRegExMatches = ['', '', '', '', '', '', '', '', '', ''];
183190
const sep = '\u0000\u0000\u0000';

test/parallel/test-repl-options.js

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ const ArrayStream = require('../common/arraystream');
2525
const assert = require('assert');
2626
const repl = require('repl');
2727

28+
common.expectWarning({
29+
DeprecationWarning: {
30+
DEP0XXX: 'REPLServer.rli is deprecated'
31+
}
32+
});
33+
2834
// Create a dummy stream that does nothing
2935
const stream = new ArrayStream();
3036

0 commit comments

Comments
 (0)