Skip to content

Commit

Permalink
Get rid of readline2 - since Node 0.10 it is now stable enough for ou…
Browse files Browse the repository at this point in the history
…r needs

Rel #272
  • Loading branch information
SBoudrias committed Apr 16, 2016
1 parent 5ef4e0a commit 6647121
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
1 change: 0 additions & 1 deletion lib/prompts/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ Prompt.prototype.render = function (error) {
bottomContent = chalk.red('>> ') + error;
}


this.screen.render(message, bottomContent);
};

Expand Down
23 changes: 19 additions & 4 deletions lib/ui/baseUI.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';
var _ = require('lodash');
var readlineFacade = require('readline2');
var MuteStream = require('mute-stream');
var readline = require('readline');

/**
* Base interface class other can inherits from
Expand All @@ -10,9 +11,7 @@ var UI = module.exports = function (opt) {
// Instantiate the Readline interface
// @Note: Don't reassign if already present (allow test to override the Stream)
if (!this.rl) {
this.rl = readlineFacade.createInterface(_.extend({
terminal: true
}, opt));
this.rl = readline.createInterface(setupReadlineOptions(opt));
}
this.rl.resume();

Expand Down Expand Up @@ -50,3 +49,19 @@ UI.prototype.close = function () {
this.rl.pause();
this.rl.close();
};

function setupReadlineOptions(opt) {
opt = opt || {};

// Default `input` to stdin
opt.input = opt.input || process.stdin;

// Add mute capabilities to the output
var ms = new MuteStream();
ms.pipe(opt.output || process.stdout);
opt.output = ms;

return _.extend({
terminal: true
}, opt);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"cli-width": "^2.0.0",
"figures": "^1.3.5",
"lodash": "^4.3.0",
"mute-stream": "0.0.6",
"pinkie-promise": "^2.0.0",
"readline2": "^1.0.1",
"run-async": "^2.2.0",
"rx": "^4.1.0",
"string-width": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion test/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var ReadlineStub = require('./helpers/readline');

mockery.enable();
mockery.warnOnUnregistered(false);
mockery.registerMock('readline2', {
mockery.registerMock('readline', {
createInterface: function () {
return new ReadlineStub();
}
Expand Down

0 comments on commit 6647121

Please sign in to comment.