mirror of https://github.com/nodejs/node.git
repl: make REPLServer inherit from EventEmitter
This is because it should emit an "exit" event when "SIGINT" is received from the readline interface, or when ".exit" is typed by the user.pull/24503/head
parent
109b16d488
commit
4f63f9f327
|
@ -41,10 +41,12 @@
|
|||
*/
|
||||
|
||||
var util = require('util');
|
||||
var inherits = require('util').inherits;
|
||||
var vm = require('vm');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var rl = require('readline');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
// If obj.hasOwnProperty has been overridden, then calling
|
||||
// obj.hasOwnProperty(prop) will break.
|
||||
|
@ -74,6 +76,8 @@ var builtinLibs = ['assert', 'buffer', 'child_process', 'cluster',
|
|||
|
||||
|
||||
function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
|
||||
EventEmitter.call(this);
|
||||
|
||||
var self = this;
|
||||
|
||||
self.useGlobal = useGlobal;
|
||||
|
@ -264,6 +268,7 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
|
|||
|
||||
self.displayPrompt();
|
||||
}
|
||||
inherits(REPLServer, EventEmitter);
|
||||
exports.REPLServer = REPLServer;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue