diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index b66b9c5a5c5dad..e41e942fc1f4fe 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -237,7 +237,7 @@ The `os.getNetworkInterfaces()` method is deprecated. Please use the ### DEP0024: REPLServer.prototype.convertToContext() -Type: Runtime +Type: End-of-Life The `REPLServer.prototype.convertToContext()` API is deprecated and should not be used. diff --git a/lib/repl.js b/lib/repl.js index 670dbfbc871365..051261a679ebeb 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1223,37 +1223,6 @@ function regexpEscape(s) { return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); } - -/** - * Converts commands that use var and function () to use the - * local exports.context when evaled. This provides a local context - * on the REPL. - * - * @param {String} cmd The cmd to convert. - * @return {String} The converted command. - */ -// TODO(princejwesley): Remove it prior to v8.0.0 release -// Reference: https://github.com/nodejs/node/pull/7829 -REPLServer.prototype.convertToContext = util.deprecate(function(cmd) { - const scopeVar = /^\s*var\s*([\w$]+)(.*)$/m; - const scopeFunc = /^\s*function\s*([\w$]+)/; - var matches; - - // Replaces: var foo = "bar"; with: self.context.foo = bar; - matches = scopeVar.exec(cmd); - if (matches && matches.length === 3) { - return 'self.context.' + matches[1] + matches[2]; - } - - // Replaces: function foo() {}; with: foo = function foo() {}; - matches = scopeFunc.exec(this.bufferedCommand); - if (matches && matches.length === 2) { - return matches[1] + ' = ' + this.bufferedCommand; - } - - return cmd; -}, 'replServer.convertToContext() is deprecated', 'DEP0024'); - // If the error is that we've unexpectedly ended the input, // then let the user try to recover by adding more input. function isRecoverableError(e, code) { diff --git a/test/parallel/test-repl-deprecated.js b/test/parallel/test-repl-deprecated.js deleted file mode 100644 index 551f2c3036a8c7..00000000000000 --- a/test/parallel/test-repl-deprecated.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const repl = require('repl'); - -common.expectWarning('DeprecationWarning', - 'replServer.convertToContext() is deprecated'); - -// Create a dummy stream that does nothing -const stream = new common.ArrayStream(); - -const replServer = repl.start({ - input: stream, - output: stream -}); - -const cmd = replServer.convertToContext('var name = "nodejs"'); -assert.strictEqual(cmd, 'self.context.name = "nodejs"');