diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 2886f2e9d61..695ab51f367 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3882,6 +3882,24 @@ Type: Runtime When an `args` array is passed to [`child_process.execFile`][] or [`child_process.spawn`][] with the option `{ shell: true }`, the values are not escaped, only space-separated, which can lead to shell injection. +### DEP0191: `repl.builtinModules` + + + +Type: Documentation-only (supports [`--pending-deprecation`][]) + +The `node:repl` module exports a `builtinModules` property that contains an array +of built-in modules. This was incomplete and matched the already deprecated +`repl._builtinLibs` ([DEP0142][]) instead it's better to rely +upon `require('node:module').builtinModules`. + +[DEP0142]: #dep0142-repl_builtinlibs [NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf [RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3 [RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4 diff --git a/doc/api/repl.md b/doc/api/repl.md index c7347dfb358..98dbe7c96d7 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -666,11 +666,14 @@ with REPL instances programmatically. +> Stability: 0 - Deprecated. Use [`module.builtinModules`][] instead. + * {string\[]} -A list of the names of all Node.js modules, e.g., `'http'`. +A list of the names of some Node.js modules, e.g., `'http'`. ## `repl.start([options])` @@ -929,6 +932,7 @@ avoiding open network interfaces. [`ERR_INVALID_REPL_INPUT`]: errors.md#err_invalid_repl_input [`curl(1)`]: https://curl.haxx.se/docs/manpage.html [`domain`]: domain.md +[`module.builtinModules`]: module.md#modulebuiltinmodules [`process.setUncaughtExceptionCaptureCallback()`]: process.md#processsetuncaughtexceptioncapturecallbackfn [`readline.InterfaceCompleter`]: readline.md#use-of-the-completer-function [`repl.ReplServer`]: #class-replserver diff --git a/lib/repl.js b/lib/repl.js index e61a24bb041..0a5a9187ddc 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1858,9 +1858,17 @@ module.exports = { ObjectDefineProperty(module.exports, 'builtinModules', { __proto__: null, - get: () => _builtinLibs, - set: (val) => _builtinLibs = val, - enumerable: true, + get: pendingDeprecation ? deprecate( + () => _builtinLibs, + 'repl.builtinModules is deprecated. Check module.builtinModules instead', + 'DEP0191', + ) : () => _builtinLibs, + set: pendingDeprecation ? deprecate( + (val) => _builtinLibs = val, + 'repl.builtinModules is deprecated. Check module.builtinModules instead', + 'DEP0191', + ) : (val) => _builtinLibs = val, + enumerable: false, configurable: true, }); diff --git a/test/parallel/test-repl-options.js b/test/parallel/test-repl-options.js index faaf461165e..8b4ba71f11a 100644 --- a/test/parallel/test-repl-options.js +++ b/test/parallel/test-repl-options.js @@ -29,12 +29,15 @@ const repl = require('repl'); const cp = require('child_process'); assert.strictEqual(repl.repl, undefined); + repl._builtinLibs; // eslint-disable-line no-unused-expressions +repl.builtinModules; // eslint-disable-line no-unused-expressions common.expectWarning({ DeprecationWarning: { DEP0142: 'repl._builtinLibs is deprecated. Check module.builtinModules instead', + DEP0191: 'repl.builtinModules is deprecated. Check module.builtinModules instead', DEP0141: 'repl.inputStream and repl.outputStream are deprecated. ' + 'Use repl.input and repl.output instead', }