| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9119344 commit db7bb94
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2666,6 +2666,20 @@ Type: Documentation-only | |||
| 2666 | 2666 | ||
| 2667 | 2667 | Use [`request.destroy()`][] instead of [`request.abort()`][]. | |
| 2668 | 2668 | ||
| 2669 | + <a id="DEP0XXX"></a> | ||
| 2670 | + ### DEP0XXX: `repl.inputStream` and `repl.outputStream` | ||
| 2671 | + <!-- YAML | ||
| 2672 | + changes: | ||
| 2673 | + - version: REPLACEME | ||
| 2674 | + pr-url: https://github.com/nodejs/node/pull/33294 | ||
| 2675 | + description: Documentation-only (supports [`--pending-deprecation`][]). | ||
| 2676 | + --> | ||
| 2677 | + | ||
| 2678 | + Type: Documentation-only (supports [`--pending-deprecation`][]) | ||
| 2679 | + | ||
| 2680 | + The `repl` module exported the input and output stream twice. Use `.input` | ||
| 2681 | + instead of `.inputStream` and `.output` instead of `.outputStream`. | ||
| 2682 | + | ||
| 2669 | 2683 | [`--pending-deprecation`]: cli.html#cli_pending_deprecation | |
| 2670 | 2684 | [`--throw-deprecation`]: cli.html#cli_throw_deprecation | |
| 2671 | 2685 | [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,9 +100,11 @@ const { | |||
| 100 | 100 | overrideStackTrace, | |
| 101 | 101 | } = require('internal/errors'); | |
| 102 | 102 | const { sendInspectorCommand } = require('internal/util/inspector'); | |
| 103 | - const experimentalREPLAwait = require('internal/options').getOptionValue( | ||
| 103 | + const { getOptionValue } = require('internal/options'); | ||
| 104 | + const experimentalREPLAwait = getOptionValue( | ||
| 104 | 105 | '--experimental-repl-await' | |
| 105 | 106 | ); | |
| 107 | + const pendingDeprecation = getOptionValue('--pending-deprecation'); | ||
| 106 | 108 | const { | |
| 107 | 109 | REPL_MODE_SLOPPY, | |
| 108 | 110 | REPL_MODE_STRICT, | |
@@ -220,8 +222,39 @@ function REPLServer(prompt, | |||
| 220 | 222 | const preview = options.terminal && | |
| 221 | 223 | (options.preview !== undefined ? !!options.preview : !eval_); | |
| 222 | 224 | ||
| 223 | - this.inputStream = options.input; | ||
| 224 | - this.outputStream = options.output; | ||
| 225 | + ObjectDefineProperty(this, 'inputStream', { | ||
| 226 | + get: pendingDeprecation ? | ||
| 227 | + deprecate(() => this.input, | ||
| 228 | + 'repl.inputStream and repl.outputStream is deprecated. ' + | ||
| 229 | + 'Use repl.input and repl.output instead', | ||
| 230 | + 'DEP0XXX') : | ||
| 231 | + () => this.input, | ||
| 232 | + set: pendingDeprecation ? | ||
| 233 | + deprecate((val) => this.input = val, | ||
| 234 | + 'repl.inputStream and repl.outputStream is deprecated. ' + | ||
| 235 | + 'Use repl.input and repl.output instead', | ||
| 236 | + 'DEP0XXX') : | ||
| 237 | + (val) => this.input = val, | ||
| 238 | + enumerable: false, | ||
| 239 | + configurable: true | ||
| 240 | + }); | ||
| 241 | + ObjectDefineProperty(this, 'outputStream', { | ||
| 242 | + get: pendingDeprecation ? | ||
| 243 | + deprecate(() => this.output, | ||
| 244 | + 'repl.inputStream and repl.outputStream is deprecated. ' + | ||
| 245 | + 'Use repl.input and repl.output instead', | ||
| 246 | + 'DEP0XXX') : | ||
| 247 | + () => this.output, | ||
| 248 | + set: pendingDeprecation ? | ||
| 249 | + deprecate((val) => this.output = val, | ||
| 250 | + 'repl.inputStream and repl.outputStream is deprecated. ' + | ||
| 251 | + 'Use repl.input and repl.output instead', | ||
| 252 | + 'DEP0XXX') : | ||
| 253 | + (val) => this.output = val, | ||
| 254 | + enumerable: false, | ||
| 255 | + configurable: true | ||
| 256 | + }); | ||
| 257 | + | ||
| 225 | 258 | this.useColors = !!options.useColors; | |
| 226 | 259 | this._domain = options.domain || domain.create(); | |
| 227 | 260 | this.useGlobal = !!useGlobal; | |
@@ -596,16 +629,13 @@ function REPLServer(prompt, | |||
| 596 | 629 | } | |
| 597 | 630 | // Normalize line endings. | |
| 598 | 631 | errStack += errStack.endsWith('\n') ? '' : '\n'; | |
| 599 | - self.outputStream.write(errStack); | ||
| 632 | + self.output.write(errStack); | ||
| 600 | 633 | self.clearBufferedCommand(); | |
| 601 | 634 | self.lines.level = []; | |
| 602 | 635 | self.displayPrompt(); | |
| 603 | 636 | } | |
| 604 | 637 | }); | |
| 605 | 638 | ||
| 606 | - self.resetContext(); | ||
| 607 | - self.lines.level = []; | ||
| 608 | - | ||
| 609 | 639 | self.clearBufferedCommand(); | |
| 610 | 640 | ObjectDefineProperty(this, 'bufferedCommand', { | |
| 611 | 641 | get: deprecate(() => self[kBufferedCommandSymbol], | |
@@ -627,14 +657,16 @@ function REPLServer(prompt, | |||
| 627 | 657 | } | |
| 628 | 658 | ||
| 629 | 659 | Interface.call(this, { | |
| 630 | - input: self.inputStream, | ||
| 631 | - output: self.outputStream, | ||
| 660 | + input: options.input, | ||
| 661 | + output: options.output, | ||
| 632 | 662 | completer: self.completer, | |
| 633 | 663 | terminal: options.terminal, | |
| 634 | 664 | historySize: options.historySize, | |
| 635 | 665 | prompt | |
| 636 | 666 | }); | |
| 637 | 667 | ||
| 668 | + self.resetContext(); | ||
| 669 | + | ||
| 638 | 670 | this.commands = ObjectCreate(null); | |
| 639 | 671 | defineDefaultCommands(this); | |
| 640 | 672 | ||
@@ -752,7 +784,7 @@ function REPLServer(prompt, | |||
| 752 | 784 | return; | |
| 753 | 785 | } | |
| 754 | 786 | if (!self[kBufferedCommandSymbol]) { | |
| 755 | - self.outputStream.write('Invalid REPL keyword\n'); | ||
| 787 | + self.output.write('Invalid REPL keyword\n'); | ||
| 756 | 788 | finish(null); | |
| 757 | 789 | return; | |
| 758 | 790 | } | |
@@ -769,7 +801,7 @@ function REPLServer(prompt, | |||
| 769 | 801 | _memory.call(self, cmd); | |
| 770 | 802 | ||
| 771 | 803 | if (e && !self[kBufferedCommandSymbol] && cmd.trim().startsWith('npm ')) { | |
| 772 | - self.outputStream.write('npm should be run outside of the ' + | ||
| 804 | + self.output.write('npm should be run outside of the ' + | ||
| 773 | 805 | 'node repl, in your normal shell.\n' + | |
| 774 | 806 | '(Press Control-D to exit.)\n'); | |
| 775 | 807 | self.displayPrompt(); | |
@@ -804,7 +836,7 @@ function REPLServer(prompt, | |||
| 804 | 836 | if (!self.underscoreAssigned) { | |
| 805 | 837 | self.last = ret; | |
| 806 | 838 | } | |
| 807 | - self.outputStream.write(self.writer(ret) + '\n'); | ||
| 839 | + self.output.write(self.writer(ret) + '\n'); | ||
| 808 | 840 | } | |
| 809 | 841 | ||
| 810 | 842 | // Display prompt again | |
@@ -814,10 +846,10 @@ function REPLServer(prompt, | |||
| 814 | 846 | ||
| 815 | 847 | self.on('SIGCONT', function onSigCont() { | |
| 816 | 848 | if (self.editorMode) { | |
| 817 | - self.outputStream.write(`${self._initialPrompt}.editor\n`); | ||
| 818 | - self.outputStream.write( | ||
| 849 | + self.output.write(`${self._initialPrompt}.editor\n`); | ||
| 850 | + self.output.write( | ||
| 819 | 851 | '// Entering editor mode (^D to finish, ^C to cancel)\n'); | |
| 820 | - self.outputStream.write(`${self[kBufferedCommandSymbol]}\n`); | ||
| 852 | + self.output.write(`${self[kBufferedCommandSymbol]}\n`); | ||
| 821 | 853 | self.prompt(true); | |
| 822 | 854 | } else { | |
| 823 | 855 | self.displayPrompt(true); | |
@@ -957,7 +989,7 @@ REPLServer.prototype.createContext = function() { | |||
| 957 | 989 | } | |
| 958 | 990 | } | |
| 959 | 991 | context.global = context; | |
| 960 | - const _console = new Console(this.outputStream); | ||
| 992 | + const _console = new Console(this.output); | ||
| 961 | 993 | ObjectDefineProperty(context, 'console', { | |
| 962 | 994 | configurable: true, | |
| 963 | 995 | writable: true, | |
@@ -998,7 +1030,7 @@ REPLServer.prototype.resetContext = function() { | |||
| 998 | 1030 | this.last = value; | |
| 999 | 1031 | if (!this.underscoreAssigned) { | |
| 1000 | 1032 | this.underscoreAssigned = true; | |
| 1001 | - this.outputStream.write('Expression assignment to _ now disabled.\n'); | ||
| 1033 | + this.output.write('Expression assignment to _ now disabled.\n'); | ||
| 1002 | 1034 | } | |
| 1003 | 1035 | } | |
| 1004 | 1036 | }); | |
@@ -1010,7 +1042,7 @@ REPLServer.prototype.resetContext = function() { | |||
| 1010 | 1042 | this.lastError = value; | |
| 1011 | 1043 | if (!this.underscoreErrAssigned) { | |
| 1012 | 1044 | this.underscoreErrAssigned = true; | |
| 1013 | - this.outputStream.write( | ||
| 1045 | + this.output.write( | ||
| 1014 | 1046 | 'Expression assignment to _error now disabled.\n'); | |
| 1015 | 1047 | } | |
| 1016 | 1048 | } | |
@@ -1495,7 +1527,7 @@ function defineDefaultCommands(repl) { | |||
| 1495 | 1527 | action: function() { | |
| 1496 | 1528 | this.clearBufferedCommand(); | |
| 1497 | 1529 | if (!this.useGlobal) { | |
| 1498 | - this.outputStream.write('Clearing context...\n'); | ||
| 1530 | + this.output.write('Clearing context...\n'); | ||
| 1499 | 1531 | this.resetContext(); | |
| 1500 | 1532 | } | |
| 1501 | 1533 | this.displayPrompt(); | |
@@ -1522,9 +1554,9 @@ function defineDefaultCommands(repl) { | |||
| 1522 | 1554 | const cmd = this.commands[name]; | |
| 1523 | 1555 | const spaces = ' '.repeat(longestNameLength - name.length + 3); | |
| 1524 | 1556 | const line = `.${name}${cmd.help ? spaces + cmd.help : ''}\n`; | |
| 1525 | - this.outputStream.write(line); | ||
| 1557 | + this.output.write(line); | ||
| 1526 | 1558 | } | |
| 1527 | - this.outputStream.write('\nPress ^C to abort current expression, ' + | ||
| 1559 | + this.output.write('\nPress ^C to abort current expression, ' + | ||
| 1528 | 1560 | '^D to exit the repl\n'); | |
| 1529 | 1561 | this.displayPrompt(); | |
| 1530 | 1562 | } | |
@@ -1535,9 +1567,9 @@ function defineDefaultCommands(repl) { | |||
| 1535 | 1567 | action: function(file) { | |
| 1536 | 1568 | try { | |
| 1537 | 1569 | fs.writeFileSync(file, this.lines.join('\n')); | |
| 1538 | - this.outputStream.write(`Session saved to: ${file}\n`); | ||
| 1570 | + this.output.write(`Session saved to: ${file}\n`); | ||
| 1539 | 1571 | } catch { | |
| 1540 | - this.outputStream.write(`Failed to save: ${file}\n`); | ||
| 1572 | + this.output.write(`Failed to save: ${file}\n`); | ||
| 1541 | 1573 | } | |
| 1542 | 1574 | this.displayPrompt(); | |
| 1543 | 1575 | } | |
@@ -1555,12 +1587,12 @@ function defineDefaultCommands(repl) { | |||
| 1555 | 1587 | _turnOffEditorMode(this); | |
| 1556 | 1588 | this.write('\n'); | |
| 1557 | 1589 | } else { | |
| 1558 | - this.outputStream.write( | ||
| 1590 | + this.output.write( | ||
| 1559 | 1591 | `Failed to load: ${file} is not a valid file\n` | |
| 1560 | 1592 | ); | |
| 1561 | 1593 | } | |
| 1562 | 1594 | } catch { | |
| 1563 | - this.outputStream.write(`Failed to load: ${file}\n`); | ||
| 1595 | + this.output.write(`Failed to load: ${file}\n`); | ||
| 1564 | 1596 | } | |
| 1565 | 1597 | this.displayPrompt(); | |
| 1566 | 1598 | } | |
@@ -1570,7 +1602,7 @@ function defineDefaultCommands(repl) { | |||
| 1570 | 1602 | help: 'Enter editor mode', | |
| 1571 | 1603 | action() { | |
| 1572 | 1604 | _turnOnEditorMode(this); | |
| 1573 | - this.outputStream.write( | ||
| 1605 | + this.output.write( | ||
| 1574 | 1606 | '// Entering editor mode (^D to finish, ^C to cancel)\n'); | |
| 1575 | 1607 | } | |
| 1576 | 1608 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,8 @@ common.skipIfDumbTerminal(); | |||
| 15 | 15 | const tmpdir = require('../common/tmpdir'); | |
| 16 | 16 | tmpdir.refresh(); | |
| 17 | 17 | ||
| 18 | + process.throwDeprecation = true; | ||
| 19 | + | ||
| 18 | 20 | const defaultHistoryPath = path.join(tmpdir.path, '.node_repl_history'); | |
| 19 | 21 | ||
| 20 | 22 | // Create an input stream specialized for testing an array of actions | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,8 @@ | |||
| 19 | 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | |
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 21 | 21 | ||
| 22 | + // Flags: --pending-deprecation | ||
| 23 | + | ||
| 22 | 24 | 'use strict'; | |
| 23 | 25 | const common = require('../common'); | |
| 24 | 26 | const ArrayStream = require('../common/arraystream'); | |
@@ -30,7 +32,9 @@ assert.strictEqual(repl.repl, undefined); | |||
| 30 | 32 | ||
| 31 | 33 | common.expectWarning({ | |
| 32 | 34 | DeprecationWarning: { | |
| 33 | - DEP0124: 'REPLServer.rli is deprecated' | ||
| 35 | + DEP0XXX: 'repl.inputStream and repl.outputStream is deprecated. ' + | ||
| 36 | + 'Use repl.input and repl.output instead', | ||
| 37 | + DEP0124: 'REPLServer.rli is deprecated', | ||
| 34 | 38 | } | |
| 35 | 39 | }); | |
| 36 | 40 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments