Skip to content

Commit 160da87

Browse files
dario-piotrowiczaduh95
authored andcommitted
repl: deprecate repl.builtinModules
Co-authored-by: Antoine du Hamel <[email protected]> PR-URL: #57508 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Xuguang Mei <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Zijian Liu <[email protected]>
1 parent f4572f0 commit 160da87

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

doc/api/deprecations.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,6 +3879,24 @@ Type: Runtime
38793879
When an `args` array is passed to [`child_process.execFile`][] or [`child_process.spawn`][] with the option
38803880
`{ shell: true }`, the values are not escaped, only space-separated, which can lead to shell injection.
38813881

3882+
### DEP0191: `repl.builtinModules`
3883+
3884+
<!-- YAML
3885+
changes:
3886+
- version: REPLACEME
3887+
pr-url: https://github.com/nodejs/node/pull/57508
3888+
description: Documentation-only deprecation
3889+
with `--pending-deprecation` support.
3890+
-->
3891+
3892+
Type: Documentation-only (supports [`--pending-deprecation`][])
3893+
3894+
The `node:repl` module exports a `builtinModules` property that contains an array
3895+
of built-in modules. This was incomplete and matched the already deprecated
3896+
`repl._builtinLibs` ([DEP0142][]) instead it's better to rely
3897+
upon `require('node:module').builtinModules`.
3898+
3899+
[DEP0142]: #dep0142-repl_builtinlibs
38823900
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
38833901
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
38843902
[RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4

doc/api/repl.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,14 @@ with REPL instances programmatically.
666666

667667
<!-- YAML
668668
added: v14.5.0
669+
deprecated: REPLACEME
669670
-->
670671

672+
> Stability: 0 - Deprecated. Use [`module.builtinModules`][] instead.
673+
671674
* {string\[]}
672675

673-
A list of the names of all Node.js modules, e.g., `'http'`.
676+
A list of the names of some Node.js modules, e.g., `'http'`.
674677

675678
## `repl.start([options])`
676679

@@ -929,6 +932,7 @@ avoiding open network interfaces.
929932
[`ERR_INVALID_REPL_INPUT`]: errors.md#err_invalid_repl_input
930933
[`curl(1)`]: https://curl.haxx.se/docs/manpage.html
931934
[`domain`]: domain.md
935+
[`module.builtinModules`]: module.md#modulebuiltinmodules
932936
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#processsetuncaughtexceptioncapturecallbackfn
933937
[`readline.InterfaceCompleter`]: readline.md#use-of-the-completer-function
934938
[`repl.ReplServer`]: #class-replserver

lib/repl.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,9 +1858,17 @@ module.exports = {
18581858

18591859
ObjectDefineProperty(module.exports, 'builtinModules', {
18601860
__proto__: null,
1861-
get: () => _builtinLibs,
1862-
set: (val) => _builtinLibs = val,
1863-
enumerable: true,
1861+
get: pendingDeprecation ? deprecate(
1862+
() => _builtinLibs,
1863+
'repl.builtinModules is deprecated. Check module.builtinModules instead',
1864+
'DEP0191',
1865+
) : () => _builtinLibs,
1866+
set: pendingDeprecation ? deprecate(
1867+
(val) => _builtinLibs = val,
1868+
'repl.builtinModules is deprecated. Check module.builtinModules instead',
1869+
'DEP0191',
1870+
) : (val) => _builtinLibs = val,
1871+
enumerable: false,
18641872
configurable: true,
18651873
});
18661874

test/parallel/test-repl-options.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ const repl = require('repl');
2929
const cp = require('child_process');
3030

3131
assert.strictEqual(repl.repl, undefined);
32+
3233
repl._builtinLibs; // eslint-disable-line no-unused-expressions
34+
repl.builtinModules; // eslint-disable-line no-unused-expressions
3335

3436
common.expectWarning({
3537
DeprecationWarning: {
3638
DEP0142:
3739
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
40+
DEP0191: 'repl.builtinModules is deprecated. Check module.builtinModules instead',
3841
DEP0141: 'repl.inputStream and repl.outputStream are deprecated. ' +
3942
'Use repl.input and repl.output instead',
4043
}

0 commit comments

Comments
 (0)