repl: deprecate unused function convertToContext
PR-URL: https://github.com/nodejs/node/pull/7829 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
588ee2296a
commit
488d28d391
@ -1204,7 +1204,9 @@ function regexpEscape(s) {
|
|||||||
* @param {String} cmd The cmd to convert.
|
* @param {String} cmd The cmd to convert.
|
||||||
* @return {String} The converted command.
|
* @return {String} The converted command.
|
||||||
*/
|
*/
|
||||||
REPLServer.prototype.convertToContext = function(cmd) {
|
// 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 scopeVar = /^\s*var\s*([_\w\$]+)(.*)$/m;
|
||||||
const scopeFunc = /^\s*function\s*([_\w\$]+)/;
|
const scopeFunc = /^\s*function\s*([_\w\$]+)/;
|
||||||
var matches;
|
var matches;
|
||||||
@ -1222,7 +1224,7 @@ REPLServer.prototype.convertToContext = function(cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return cmd;
|
return cmd;
|
||||||
};
|
}, 'replServer.convertToContext() is deprecated');
|
||||||
|
|
||||||
function bailOnIllegalToken(parser) {
|
function bailOnIllegalToken(parser) {
|
||||||
return parser._literal === null &&
|
return parser._literal === null &&
|
||||||
|
28
test/parallel/test-repl-deprecated.js
Normal file
28
test/parallel/test-repl-deprecated.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const repl = require('repl');
|
||||||
|
|
||||||
|
const expected = [
|
||||||
|
'replServer.convertToContext() is deprecated'
|
||||||
|
];
|
||||||
|
|
||||||
|
process.on('warning', common.mustCall((warning) => {
|
||||||
|
assert.strictEqual(warning.name, 'DeprecationWarning');
|
||||||
|
assert.notStrictEqual(expected.indexOf(warning.message), -1,
|
||||||
|
`unexpected error message: "${warning.message}"`);
|
||||||
|
// Remove a warning message after it is seen so that we guarantee that we get
|
||||||
|
// each message only once.
|
||||||
|
expected.splice(expected.indexOf(warning.message), 1);
|
||||||
|
}, expected.length));
|
||||||
|
|
||||||
|
// 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"');
|
Loading…
x
Reference in New Issue
Block a user