mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:13:31 +02:00
Refactor stream log output to a utility.
This commit is contained in:
@@ -43,7 +43,6 @@ module.exports.readAll = function(stream) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
module.exports.findLine = function(stream, re) {
|
||||
var resolver = Promise.defer()
|
||||
, piped = stream.pipe(split())
|
||||
@@ -73,3 +72,13 @@ module.exports.findLine = function(stream, re) {
|
||||
stream.unpipe(piped)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.talk = function(log, format, stream) {
|
||||
stream.pipe(split())
|
||||
.on('data', function(chunk) {
|
||||
var line = chunk.toString().trim()
|
||||
if (line.length) {
|
||||
log.info(format, line)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user