Skip to content

Commit

Permalink
Merge pull request #63 from pull-requests/memleak
Browse files Browse the repository at this point in the history
Call streams end to trigger cleanup (fix #62)
  • Loading branch information
SBoudrias committed Sep 3, 2013
2 parents 849363c + 7e4b2bd commit 7b433c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/inquirer.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ inquirer.prompt = function( questions, allDone ) {
process.stdin.removeListener( "keypress", this.onKeypress );

// Close the readline
this.rl.output.end();
this.rl.pause();
this.rl.close();
this.rl = null;
Expand Down
1 change: 1 addition & 0 deletions test/helpers/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var stub = {
pause : sinon.stub().returns(stub),
resume : sinon.stub().returns(stub),
output : {
end : sinon.stub().returns(stub),
mute : sinon.stub().returns(stub),
unmute : sinon.stub().returns(stub),
write : sinon.stub().returns(stub)
Expand Down
2 changes: 2 additions & 0 deletions test/specs/inquirer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("inquirer.prompt", function() {
var rl2;

expect(rl1.close.called).to.be.true;
expect(rl1.output.end.called).to.be.true;
expect(inquirer.rl).to.not.exist;

inquirer.prompt({
Expand All @@ -37,6 +38,7 @@ describe("inquirer.prompt", function() {
message: "message"
}, function( answers ) {
expect(rl2.close.called).to.be.true;
expect(rl2.output.end.called).to.be.true;
expect(inquirer.rl).to.not.exist;

expect( rl1 ).to.not.equal( rl2 );
Expand Down

0 comments on commit 7b433c7

Please sign in to comment.