Skip to content

Commit

Permalink
repl: runtime deprecate 04141 and 04142
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Sep 3, 2024
1 parent b7b9628 commit ea81bf7
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 67 deletions.
10 changes: 8 additions & 2 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2874,12 +2874,15 @@ Use [`request.destroy()`][] instead of [`request.abort()`][].

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/54750
description: Runtime Deprecation.
- version: v14.3.0
pr-url: https://github.com/nodejs/node/pull/33294
description: Documentation-only (supports [`--pending-deprecation`][]).
-->

Type: Documentation-only (supports [`--pending-deprecation`][])
Type: Runtime

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

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/54750
description: Runtime Deprecation.
- version: v14.3.0
pr-url: https://github.com/nodejs/node/pull/33294
description: Documentation-only (supports [`--pending-deprecation`][]).
-->

Type: Documentation-only
Type: Runtime

The `node:repl` module exports a `_builtinLibs` property that contains an array
of built-in modules. It was incomplete so far and instead it's better to rely
Expand Down
43 changes: 16 additions & 27 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ const {
const experimentalREPLAwait = getOptionValue(
'--experimental-repl-await',
);
const pendingDeprecation = getOptionValue('--pending-deprecation');
const {
REPL_MODE_SLOPPY,
REPL_MODE_STRICT,
Expand Down Expand Up @@ -312,35 +311,27 @@ function REPLServer(prompt,

ObjectDefineProperty(this, 'inputStream', {
__proto__: null,
get: pendingDeprecation ?
deprecate(() => this.input,
'repl.inputStream and repl.outputStream are deprecated. ' +
get: deprecate(() => this.input,
'repl.inputStream and repl.outputStream are deprecated. ' +
'Use repl.input and repl.output instead',
'DEP0141') :
() => this.input,
set: pendingDeprecation ?
deprecate((val) => this.input = val,
'repl.inputStream and repl.outputStream are deprecated. ' +
'DEP0141'),
set: deprecate((val) => this.input = val,
'repl.inputStream and repl.outputStream are deprecated. ' +
'Use repl.input and repl.output instead',
'DEP0141') :
(val) => this.input = val,
'DEP0141'),
enumerable: false,
configurable: true,
});
ObjectDefineProperty(this, 'outputStream', {
__proto__: null,
get: pendingDeprecation ?
deprecate(() => this.output,
'repl.inputStream and repl.outputStream are deprecated. ' +
get: deprecate(() => this.output,
'repl.inputStream and repl.outputStream are deprecated. ' +
'Use repl.input and repl.output instead',
'DEP0141') :
() => this.output,
set: pendingDeprecation ?
deprecate((val) => this.output = val,
'repl.inputStream and repl.outputStream are deprecated. ' +
'DEP0141'),
set: deprecate((val) => this.output = val,
'repl.inputStream and repl.outputStream are deprecated. ' +
'Use repl.input and repl.output instead',
'DEP0141') :
(val) => this.output = val,
'DEP0141'),
enumerable: false,
configurable: true,
});
Expand Down Expand Up @@ -1873,16 +1864,14 @@ ObjectDefineProperty(module.exports, 'builtinModules', {

ObjectDefineProperty(module.exports, '_builtinLibs', {
__proto__: null,
get: pendingDeprecation ? deprecate(
get: deprecate(
() => _builtinLibs,
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
'DEP0142',
) : () => _builtinLibs,
set: pendingDeprecation ? deprecate(
'DEP0142'),
set: deprecate(
(val) => _builtinLibs = val,
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
'DEP0142',
) : (val) => _builtinLibs = val,
'DEP0142'),
enumerable: false,
configurable: true,
});
16 changes: 0 additions & 16 deletions test/parallel/test-repl-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// Flags: --pending-deprecation

'use strict';
const common = require('../common');
const ArrayStream = require('../common/arraystream');
Expand All @@ -29,16 +27,6 @@ const repl = require('repl');
const cp = require('child_process');

assert.strictEqual(repl.repl, undefined);
repl._builtinLibs; // eslint-disable-line no-unused-expressions

common.expectWarning({
DeprecationWarning: {
DEP0142:
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
DEP0141: 'repl.inputStream and repl.outputStream are deprecated. ' +
'Use repl.input and repl.output instead',
}
});

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

assert.strictEqual(r1.input, stream);
assert.strictEqual(r1.output, stream);
assert.strictEqual(r1.input, r1.inputStream);
assert.strictEqual(r1.output, r1.outputStream);
assert.strictEqual(r1.terminal, true);
assert.strictEqual(r1.useColors, false);
assert.strictEqual(r1.useGlobal, false);
Expand All @@ -79,8 +65,6 @@ const r2 = repl.start({
});
assert.strictEqual(r2.input, stream);
assert.strictEqual(r2.output, stream);
assert.strictEqual(r2.input, r2.inputStream);
assert.strictEqual(r2.output, r2.outputStream);
assert.strictEqual(r2.terminal, false);
assert.strictEqual(r2.useColors, true);
assert.strictEqual(r2.useGlobal, true);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-persistent-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,6 @@ function runTest(assertCleaned) {
}
}

repl.inputStream.run(test);
repl.input.run(test);
});
}
6 changes: 3 additions & 3 deletions test/parallel/test-repl-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class REPLStream extends Stream {
}

function runAndWait(cmds, repl) {
const promise = repl.inputStream.wait();
const promise = repl.input.wait();
for (const cmd of cmds) {
repl.inputStream.run(cmd);
repl.input.run(cmd);
}
return promise;
}
Expand All @@ -65,7 +65,7 @@ async function tests(options) {
...options
});

repl.inputStream.run([
repl.input.run([
'function foo(x) { return x; }',
'function koo() { console.log("abc"); }',
'a = undefined;',
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-programmatic-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,6 @@ function runTest(assertCleaned) {
}
}

repl.inputStream.run(test);
repl.input.run(test);
});
}
2 changes: 1 addition & 1 deletion test/parallel/test-repl-reverse-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function runTest() {
enumerable: true
});
}
repl.inputStream.run(opts.test);
repl.input.run(opts.test);
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-strict-mode-previews.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (process.argv[2] === 'child') {
}),
useColors: false,
terminal: true
}).inputStream.run('xyz');
}).input.run('xyz');
} else {
const assert = require('assert');
const { spawnSync } = require('child_process');
Expand Down
8 changes: 0 additions & 8 deletions test/parallel/test-repl-tab-complete-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ testMe.complete('import(\'', common.mustCall((error, data) => {
`${lib} not found`,
);
});
const newModule = 'foobar';
assert(!builtinModules.includes(newModule));
repl.builtinModules.push(newModule);
testMe.complete('import(\'', common.mustCall((_, [modules]) => {
assert.strictEqual(data[0].length + 1, modules.length);
assert(modules.includes(newModule) &&
!modules.includes(`node:${newModule}`));
}));
}));

testMe.complete("import\t( 'n", common.mustCall((error, data) => {
Expand Down
7 changes: 0 additions & 7 deletions test/parallel/test-repl-tab-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,6 @@ testMe.complete('require(\'', common.mustCall(function(error, data) {
`${lib} not found`
);
});
const newModule = 'foobar';
assert(!builtinModules.includes(newModule));
repl.builtinModules.push(newModule);
testMe.complete('require(\'', common.mustCall((_, [modules]) => {
assert.strictEqual(data[0].length + 1, modules.length);
assert(modules.includes(newModule));
}));
}));

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

0 comments on commit ea81bf7

Please sign in to comment.