Revert "repl: fix overwrite for this._prompt"
This reverts commit 7166b55015261de8ab69758320f3d9159b3eaadd.
This commit is contained in:
parent
bae019f182
commit
1a52d6abcc
@ -49,7 +49,6 @@ function Interface(input, output, completer, terminal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._sawReturn = false;
|
this._sawReturn = false;
|
||||||
this._defaultPrompt = '> ';
|
|
||||||
|
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ function Interface(input, output, completer, terminal) {
|
|||||||
callback(null, completer(v));
|
callback(null, completer(v));
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setDefaultPrompt();
|
this.setPrompt('> ');
|
||||||
|
|
||||||
this.terminal = !!terminal;
|
this.terminal = !!terminal;
|
||||||
|
|
||||||
@ -164,11 +163,6 @@ Interface.prototype.setPrompt = function(prompt) {
|
|||||||
this._prompt = prompt;
|
this._prompt = prompt;
|
||||||
};
|
};
|
||||||
|
|
||||||
Interface.prototype.setDefaultPrompt = function(prompt) {
|
|
||||||
if (!util.isUndefined(prompt))
|
|
||||||
this._defaultPrompt = prompt;
|
|
||||||
this._prompt = this._defaultPrompt;
|
|
||||||
};
|
|
||||||
|
|
||||||
Interface.prototype._setRawMode = function(mode) {
|
Interface.prototype._setRawMode = function(mode) {
|
||||||
if (util.isFunction(this.input.setRawMode)) {
|
if (util.isFunction(this.input.setRawMode)) {
|
||||||
|
10
lib/repl.js
10
lib/repl.js
@ -193,7 +193,7 @@ function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
|
|||||||
options.terminal
|
options.terminal
|
||||||
]);
|
]);
|
||||||
|
|
||||||
self.setDefaultPrompt(prompt);
|
self.setPrompt(!util.isUndefined(prompt) ? prompt : '> ');
|
||||||
|
|
||||||
this.commands = {};
|
this.commands = {};
|
||||||
defineDefaultCommands(this);
|
defineDefaultCommands(this);
|
||||||
@ -389,16 +389,16 @@ REPLServer.prototype.resetContext = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
REPLServer.prototype.displayPrompt = function(preserveCursor) {
|
REPLServer.prototype.displayPrompt = function(preserveCursor) {
|
||||||
var prompt = this._prompt;
|
var initial = this._prompt;
|
||||||
|
var prompt = initial;
|
||||||
if (this.bufferedCommand.length) {
|
if (this.bufferedCommand.length) {
|
||||||
prompt = '...';
|
prompt = '...';
|
||||||
var levelInd = new Array(this.lines.level.length).join('..');
|
var levelInd = new Array(this.lines.level.length).join('..');
|
||||||
prompt += levelInd + ' ';
|
prompt += levelInd + ' ';
|
||||||
this.setPrompt(prompt);
|
|
||||||
} else {
|
|
||||||
this.setDefaultPrompt();
|
|
||||||
}
|
}
|
||||||
|
this.setPrompt(prompt);
|
||||||
this.prompt(preserveCursor);
|
this.prompt(preserveCursor);
|
||||||
|
this.setPrompt(initial);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A stream to push an array into a REPL
|
// A stream to push an array into a REPL
|
||||||
|
@ -34,8 +34,7 @@ var net = require('net'),
|
|||||||
'node repl, in your normal shell.\n' +
|
'node repl, in your normal shell.\n' +
|
||||||
'(Press Control-D to exit.)\n',
|
'(Press Control-D to exit.)\n',
|
||||||
expect_npm = prompt_npm + prompt_unix,
|
expect_npm = prompt_npm + prompt_unix,
|
||||||
server_tcp, server_unix, client_tcp, client_unix, timer,
|
server_tcp, server_unix, client_tcp, client_unix, timer;
|
||||||
repl_unix;
|
|
||||||
|
|
||||||
|
|
||||||
// absolute path to test/fixtures/a.js
|
// absolute path to test/fixtures/a.js
|
||||||
@ -100,7 +99,6 @@ function error_test() {
|
|||||||
} else if (read_buffer.indexOf(prompt_multiline) !== -1) {
|
} else if (read_buffer.indexOf(prompt_multiline) !== -1) {
|
||||||
// Check that you meant to send a multiline test
|
// Check that you meant to send a multiline test
|
||||||
assert.strictEqual(prompt_multiline, client_unix.expect);
|
assert.strictEqual(prompt_multiline, client_unix.expect);
|
||||||
assert.equal(repl_unix._prompt, prompt_multiline);
|
|
||||||
read_buffer = '';
|
read_buffer = '';
|
||||||
if (client_unix.list && client_unix.list.length > 0) {
|
if (client_unix.list && client_unix.list.length > 0) {
|
||||||
send_expect(client_unix.list);
|
send_expect(client_unix.list);
|
||||||
@ -277,13 +275,12 @@ function unix_test() {
|
|||||||
socket.end();
|
socket.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
repl_unix = repl.start({
|
repl.start({
|
||||||
prompt: prompt_unix,
|
prompt: prompt_unix,
|
||||||
input: socket,
|
input: socket,
|
||||||
output: socket,
|
output: socket,
|
||||||
useGlobal: true
|
useGlobal: true
|
||||||
});
|
}).context.message = message;
|
||||||
repl_unix.context.message = message;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server_unix.on('listening', function() {
|
server_unix.on('listening', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user