From 4f63f9f327857a7ebb1021b55d9ed3bf7cf8d817 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 12 Mar 2012 17:25:51 -0700 Subject: [PATCH] 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. --- lib/repl.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/repl.js b/lib/repl.js index 9c5feb281d1..07260611f4f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -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;