|
@ -27,6 +27,7 @@ |
|
|
|
|
|
|
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
const errors = require('internal/errors'); |
|
|
const { debug, inherits } = require('util'); |
|
|
const { debug, inherits } = require('util'); |
|
|
const Buffer = require('buffer').Buffer; |
|
|
const Buffer = require('buffer').Buffer; |
|
|
const EventEmitter = require('events'); |
|
|
const EventEmitter = require('events'); |
|
@ -95,7 +96,7 @@ function Interface(input, output, completer, terminal) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (completer && typeof completer !== 'function') { |
|
|
if (completer && typeof completer !== 'function') { |
|
|
throw new TypeError('Argument "completer" must be a function'); |
|
|
throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'completer', completer); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (historySize === undefined) { |
|
|
if (historySize === undefined) { |
|
@ -105,7 +106,11 @@ function Interface(input, output, completer, terminal) { |
|
|
if (typeof historySize !== 'number' || |
|
|
if (typeof historySize !== 'number' || |
|
|
isNaN(historySize) || |
|
|
isNaN(historySize) || |
|
|
historySize < 0) { |
|
|
historySize < 0) { |
|
|
throw new TypeError('Argument "historySize" must be a positive number'); |
|
|
throw new errors.RangeError( |
|
|
|
|
|
'ERR_INVALID_OPT_VALUE', |
|
|
|
|
|
'historySize', |
|
|
|
|
|
historySize |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// backwards compat; check the isTTY prop of the output stream
|
|
|
// backwards compat; check the isTTY prop of the output stream
|
|
@ -281,7 +286,12 @@ Interface.prototype._onLine = function(line) { |
|
|
|
|
|
|
|
|
Interface.prototype._writeToOutput = function _writeToOutput(stringToWrite) { |
|
|
Interface.prototype._writeToOutput = function _writeToOutput(stringToWrite) { |
|
|
if (typeof stringToWrite !== 'string') |
|
|
if (typeof stringToWrite !== 'string') |
|
|
throw new TypeError('"stringToWrite" argument must be a string'); |
|
|
throw new errors.TypeError( |
|
|
|
|
|
'ERR_INVALID_ARG_TYPE', |
|
|
|
|
|
'stringToWrite', |
|
|
|
|
|
'string', |
|
|
|
|
|
stringToWrite |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
if (this.output !== null && this.output !== undefined) |
|
|
if (this.output !== null && this.output !== undefined) |
|
|
this.output.write(stringToWrite); |
|
|
this.output.write(stringToWrite); |
|
@ -1053,7 +1063,7 @@ function cursorTo(stream, x, y) { |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
if (typeof x !== 'number') |
|
|
if (typeof x !== 'number') |
|
|
throw new Error('Can\'t set cursor row without also setting it\'s column'); |
|
|
throw new errors.Error('ERR_INVALID_CURSOR_POS'); |
|
|
|
|
|
|
|
|
if (typeof y !== 'number') { |
|
|
if (typeof y !== 'number') { |
|
|
stream.write(CSI`${x + 1}G`); |
|
|
stream.write(CSI`${x + 1}G`); |
|
|