serverline-sim/src/logHook.ts

18 lines
420 B
TypeScript
Raw Normal View History

2021-12-12 10:53:26 -05:00
import { appendFileSync } from 'fs'
import { EventEmitter } from 'events'
const events = new EventEmitter();
2021-12-22 04:25:12 -05:00
type WriteFunction = typeof process.stdout.write;
process.stdout.write = (function(write: WriteFunction): WriteFunction {
return function(string: string): boolean {
2021-12-12 10:53:26 -05:00
events.emit('data', string);
2021-12-22 04:25:12 -05:00
return write.apply(process.stdout, arguments);
2021-12-12 10:53:26 -05:00
};
})(process.stdout.write);
export default events;