Comparing version 0.1.7 to 0.1.8
@@ -47,2 +47,3 @@ /** | ||
this.rl || (this.rl = readlineFacade.createInterface()); | ||
this.rl.resume(); | ||
@@ -58,4 +59,6 @@ // Keep global reference to the answers | ||
// Propagate keypress events directly on the readline | ||
// Make sure to check if rl exist because keypress (\r) will be triggered after rl "line" | ||
// events | ||
process.stdin.on("keypress", function( s, key ) { | ||
self.rl.emit( "keypress", s, key ); | ||
self.rl && self.rl.emit( "keypress", s, key ); | ||
}); | ||
@@ -102,2 +105,3 @@ | ||
self.rl.close(); | ||
self.rl = null; | ||
@@ -104,0 +108,0 @@ if ( _.isFunction(allDone) ) { |
{ | ||
"name": "inquirer", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "A collection of common interactive command line user interfaces.", | ||
@@ -5,0 +5,0 @@ "main": "lib/inquirer.js", |
var EventEmitter = require("events").EventEmitter; | ||
var sinon = require("sinon"); | ||
var util = require("util"); | ||
var _ = require("lodash"); | ||
var noop = function() { return stub; }; | ||
var stub = { | ||
write : noop, | ||
moveCursor : noop, | ||
setPrompt : noop, | ||
close : noop, | ||
write : sinon.stub().returns(stub), | ||
moveCursor : sinon.stub().returns(stub), | ||
setPrompt : sinon.stub().returns(stub), | ||
close : sinon.stub().returns(stub), | ||
resume : sinon.stub().returns(stub), | ||
output : { | ||
mute : noop, | ||
unmute : noop, | ||
write : noop | ||
mute : sinon.stub().returns(stub), | ||
unmute : sinon.stub().returns(stub), | ||
write : sinon.stub().returns(stub) | ||
} | ||
@@ -16,0 +17,0 @@ }; |
@@ -11,6 +11,40 @@ /** | ||
inquirer.rl = new ReadlineStub(); | ||
describe("inquirer.prompt", function() { | ||
beforeEach(function() { | ||
inquirer.rl = new ReadlineStub(); | ||
}); | ||
it("should resume and close readline", function( done ) { | ||
var rl = inquirer.rl; | ||
inquirer.prompt({ | ||
type: "confirm", | ||
name: "q1", | ||
message: "message" | ||
}, function( answers ) { | ||
expect(inquirer.rl).to.not.exist; | ||
expect(rl.resume.called).to.be.true; | ||
expect(rl.close.called).to.be.true; | ||
rl = inquirer.rl = new ReadlineStub(); | ||
inquirer.prompt({ | ||
type: "confirm", | ||
name: "q1", | ||
message: "message" | ||
}, function( answers ) { | ||
expect(inquirer.rl).to.not.exist; | ||
expect(rl.resume.called).to.be.true; | ||
expect(rl.close.called).to.be.true; | ||
done(); | ||
}); | ||
inquirer.rl.emit("line"); | ||
}); | ||
rl.emit("line"); | ||
}); | ||
it("should take a prompts array and return answers", function( done ) { | ||
@@ -17,0 +51,0 @@ var prompts = [{ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1681
79807