mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
28 lines
576 B
JavaScript
28 lines
576 B
JavaScript
var events = require('events'),
|
|
util = require('util');
|
|
|
|
var Bus = function () {
|
|
events.EventEmitter.call(this);
|
|
};
|
|
|
|
util.inherits(Bus, events.EventEmitter);
|
|
|
|
var bus = new Bus();
|
|
|
|
// proxy process messages (if forked) to the bus
|
|
process.on('message', function (event) {
|
|
bus.emit(event);
|
|
});
|
|
|
|
var emit = bus.emit;
|
|
|
|
// if nodemon was spawned via a fork, allow upstream communication
|
|
// via process.send
|
|
if (process.send) {
|
|
bus.emit = function (event, data) {
|
|
process.send({ type: event, data: data });
|
|
emit.apply(bus, arguments);
|
|
};
|
|
}
|
|
|
|
module.exports = bus; |