forked from ugumba/homey-panasonic-comfort-cloud-alt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook.js
26 lines (21 loc) · 755 Bytes
/
hook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function hook_stdouterr(callback) {
var old_stdout_write = process.stdout.write
var old_stderr_write = process.stderr.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
}
})(process.stdout.write)
process.stderr.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stderr, arguments)
callback(string, encoding, fd)
}
})(process.stderr.write)
return function() {
process.stdout.write = old_stdout_write
process.stderr.write = old_stderr_write
}
}
module.exports = hook_stdouterr;