Skip to content

Commit 4f4397f

Browse files
committed
repl: runtime deprecate inputStream, outputStream and _builtinLibs
1 parent b7b9628 commit 4f4397f

10 files changed

+31
-67
lines changed

doc/api/deprecations.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,12 +2874,15 @@ Use [`request.destroy()`][] instead of [`request.abort()`][].
28742874

28752875
<!-- YAML
28762876
changes:
2877+
- version: REPLACEME
2878+
pr-url: https://github.com/nodejs/node/pull/54750
2879+
description: Runtime Deprecation.
28772880
- version: v14.3.0
28782881
pr-url: https://github.com/nodejs/node/pull/33294
28792882
description: Documentation-only (supports [`--pending-deprecation`][]).
28802883
-->
28812884

2882-
Type: Documentation-only (supports [`--pending-deprecation`][])
2885+
Type: Runtime
28832886

28842887
The `node:repl` module exported the input and output stream twice. Use `.input`
28852888
instead of `.inputStream` and `.output` instead of `.outputStream`.
@@ -2888,12 +2891,15 @@ instead of `.inputStream` and `.output` instead of `.outputStream`.
28882891

28892892
<!-- YAML
28902893
changes:
2894+
- version: REPLACEME
2895+
pr-url: https://github.com/nodejs/node/pull/54750
2896+
description: Runtime Deprecation.
28912897
- version: v14.3.0
28922898
pr-url: https://github.com/nodejs/node/pull/33294
28932899
description: Documentation-only (supports [`--pending-deprecation`][]).
28942900
-->
28952901

2896-
Type: Documentation-only
2902+
Type: Runtime
28972903

28982904
The `node:repl` module exports a `_builtinLibs` property that contains an array
28992905
of built-in modules. It was incomplete so far and instead it's better to rely

lib/repl.js

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ const {
163163
const experimentalREPLAwait = getOptionValue(
164164
'--experimental-repl-await',
165165
);
166-
const pendingDeprecation = getOptionValue('--pending-deprecation');
167166
const {
168167
REPL_MODE_SLOPPY,
169168
REPL_MODE_STRICT,
@@ -312,35 +311,27 @@ function REPLServer(prompt,
312311

313312
ObjectDefineProperty(this, 'inputStream', {
314313
__proto__: null,
315-
get: pendingDeprecation ?
316-
deprecate(() => this.input,
317-
'repl.inputStream and repl.outputStream are deprecated. ' +
314+
get: deprecate(() => this.input,
315+
'repl.inputStream and repl.outputStream are deprecated. ' +
318316
'Use repl.input and repl.output instead',
319-
'DEP0141') :
320-
() => this.input,
321-
set: pendingDeprecation ?
322-
deprecate((val) => this.input = val,
323-
'repl.inputStream and repl.outputStream are deprecated. ' +
317+
'DEP0141'),
318+
set: deprecate((val) => this.input = val,
319+
'repl.inputStream and repl.outputStream are deprecated. ' +
324320
'Use repl.input and repl.output instead',
325-
'DEP0141') :
326-
(val) => this.input = val,
321+
'DEP0141'),
327322
enumerable: false,
328323
configurable: true,
329324
});
330325
ObjectDefineProperty(this, 'outputStream', {
331326
__proto__: null,
332-
get: pendingDeprecation ?
333-
deprecate(() => this.output,
334-
'repl.inputStream and repl.outputStream are deprecated. ' +
327+
get: deprecate(() => this.output,
328+
'repl.inputStream and repl.outputStream are deprecated. ' +
335329
'Use repl.input and repl.output instead',
336-
'DEP0141') :
337-
() => this.output,
338-
set: pendingDeprecation ?
339-
deprecate((val) => this.output = val,
340-
'repl.inputStream and repl.outputStream are deprecated. ' +
330+
'DEP0141'),
331+
set: deprecate((val) => this.output = val,
332+
'repl.inputStream and repl.outputStream are deprecated. ' +
341333
'Use repl.input and repl.output instead',
342-
'DEP0141') :
343-
(val) => this.output = val,
334+
'DEP0141'),
344335
enumerable: false,
345336
configurable: true,
346337
});
@@ -1873,16 +1864,14 @@ ObjectDefineProperty(module.exports, 'builtinModules', {
18731864

18741865
ObjectDefineProperty(module.exports, '_builtinLibs', {
18751866
__proto__: null,
1876-
get: pendingDeprecation ? deprecate(
1867+
get: deprecate(
18771868
() => _builtinLibs,
18781869
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
1879-
'DEP0142',
1880-
) : () => _builtinLibs,
1881-
set: pendingDeprecation ? deprecate(
1870+
'DEP0142'),
1871+
set: deprecate(
18821872
(val) => _builtinLibs = val,
18831873
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
1884-
'DEP0142',
1885-
) : (val) => _builtinLibs = val,
1874+
'DEP0142'),
18861875
enumerable: false,
18871876
configurable: true,
18881877
});

test/parallel/test-repl-options.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

22-
// Flags: --pending-deprecation
23-
2422
'use strict';
2523
const common = require('../common');
2624
const ArrayStream = require('../common/arraystream');
@@ -29,16 +27,6 @@ const repl = require('repl');
2927
const cp = require('child_process');
3028

3129
assert.strictEqual(repl.repl, undefined);
32-
repl._builtinLibs; // eslint-disable-line no-unused-expressions
33-
34-
common.expectWarning({
35-
DeprecationWarning: {
36-
DEP0142:
37-
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
38-
DEP0141: 'repl.inputStream and repl.outputStream are deprecated. ' +
39-
'Use repl.input and repl.output instead',
40-
}
41-
});
4230

4331
// Create a dummy stream that does nothing
4432
const stream = new ArrayStream();
@@ -52,8 +40,6 @@ const r1 = repl.start({
5240

5341
assert.strictEqual(r1.input, stream);
5442
assert.strictEqual(r1.output, stream);
55-
assert.strictEqual(r1.input, r1.inputStream);
56-
assert.strictEqual(r1.output, r1.outputStream);
5743
assert.strictEqual(r1.terminal, true);
5844
assert.strictEqual(r1.useColors, false);
5945
assert.strictEqual(r1.useGlobal, false);
@@ -79,8 +65,6 @@ const r2 = repl.start({
7965
});
8066
assert.strictEqual(r2.input, stream);
8167
assert.strictEqual(r2.output, stream);
82-
assert.strictEqual(r2.input, r2.inputStream);
83-
assert.strictEqual(r2.output, r2.outputStream);
8468
assert.strictEqual(r2.terminal, false);
8569
assert.strictEqual(r2.useColors, true);
8670
assert.strictEqual(r2.useGlobal, true);

test/parallel/test-repl-persistent-history.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,6 @@ function runTest(assertCleaned) {
265265
}
266266
}
267267

268-
repl.inputStream.run(test);
268+
repl.input.run(test);
269269
});
270270
}

test/parallel/test-repl-preview.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class REPLStream extends Stream {
4949
}
5050

5151
function runAndWait(cmds, repl) {
52-
const promise = repl.inputStream.wait();
52+
const promise = repl.input.wait();
5353
for (const cmd of cmds) {
54-
repl.inputStream.run(cmd);
54+
repl.input.run(cmd);
5555
}
5656
return promise;
5757
}
@@ -65,7 +65,7 @@ async function tests(options) {
6565
...options
6666
});
6767

68-
repl.inputStream.run([
68+
repl.input.run([
6969
'function foo(x) { return x; }',
7070
'function koo() { console.log("abc"); }',
7171
'a = undefined;',

test/parallel/test-repl-programmatic-history.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,6 @@ function runTest(assertCleaned) {
265265
}
266266
}
267267

268-
repl.inputStream.run(test);
268+
repl.input.run(test);
269269
});
270270
}

test/parallel/test-repl-reverse-search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function runTest() {
352352
enumerable: true
353353
});
354354
}
355-
repl.inputStream.run(opts.test);
355+
repl.input.run(opts.test);
356356
});
357357
}
358358

test/parallel/test-repl-strict-mode-previews.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if (process.argv[2] === 'child') {
3030
}),
3131
useColors: false,
3232
terminal: true
33-
}).inputStream.run('xyz');
33+
}).input.run('xyz');
3434
} else {
3535
const assert = require('assert');
3636
const { spawnSync } = require('child_process');

test/parallel/test-repl-tab-complete-import.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ testMe.complete('import(\'', common.mustCall((error, data) => {
3737
`${lib} not found`,
3838
);
3939
});
40-
const newModule = 'foobar';
41-
assert(!builtinModules.includes(newModule));
42-
repl.builtinModules.push(newModule);
43-
testMe.complete('import(\'', common.mustCall((_, [modules]) => {
44-
assert.strictEqual(data[0].length + 1, modules.length);
45-
assert(modules.includes(newModule) &&
46-
!modules.includes(`node:${newModule}`));
47-
}));
4840
}));
4941

5042
testMe.complete("import\t( 'n", common.mustCall((error, data) => {

test/parallel/test-repl-tab-complete.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,6 @@ testMe.complete('require(\'', common.mustCall(function(error, data) {
279279
`${lib} not found`
280280
);
281281
});
282-
const newModule = 'foobar';
283-
assert(!builtinModules.includes(newModule));
284-
repl.builtinModules.push(newModule);
285-
testMe.complete('require(\'', common.mustCall((_, [modules]) => {
286-
assert.strictEqual(data[0].length + 1, modules.length);
287-
assert(modules.includes(newModule));
288-
}));
289282
}));
290283

291284
testMe.complete("require\t( 'n", common.mustCall(function(error, data) {

0 commit comments

Comments
 (0)