Fix: setPrompt() changes prompt to '' if no argument.

This commit is contained in:
anseki 2014-07-13 21:30:04 +09:00
parent 06254667d6
commit 03cdd60eb6
2 changed files with 5 additions and 3 deletions

View file

@ -24,7 +24,7 @@ var
function _readlineSync(display, options) { function _readlineSync(display, options) {
var input = '', rsize, err; var input = '', rsize, err;
if (display !== '') { if (display !== '') { // null and undefined were excluded.
if (typeof print === 'function') { print(display, encoding); } if (typeof print === 'function') { print(display, encoding); }
stdout.write(display + '', encoding); stdout.write(display + '', encoding);
} }
@ -154,8 +154,10 @@ exports.setPrint = function(fnc) { print = fnc; };
exports.setPrompt = function(newPrompt) { exports.setPrompt = function(newPrompt) {
/* jshint eqnull:true */ /* jshint eqnull:true */
promptText = newPrompt != null ? newPrompt : ''; if (newPrompt != null) {
/* jshint eqnull:false */ /* jshint eqnull:false */
promptText = newPrompt;
}
return promptText; return promptText;
}; };

View file

@ -1,7 +1,7 @@
{ {
"name": "readline-sync", "name": "readline-sync",
"description": "Synchronous Readline", "description": "Synchronous Readline",
"version": "0.4.4", "version": "0.4.5",
"homepage": "https://github.com/anseki/readline-sync", "homepage": "https://github.com/anseki/readline-sync",
"author": { "author": {
"name": "anseki" "name": "anseki"