mirror of https://github.com/mthenw/frontail.git
use byline also for stdin
parent
bc8eb6cada
commit
756cbee2a5
11
lib/tail.js
11
lib/tail.js
|
@ -17,13 +17,10 @@ function Tail(path, opts) {
|
|||
this._buffer = new CBuffer(options.buffer);
|
||||
|
||||
if (path[0] === '-') {
|
||||
process.stdin.setEncoding('utf8');
|
||||
|
||||
process.stdin.on('readable', () => {
|
||||
const line = process.stdin.read();
|
||||
if (line !== null) {
|
||||
this.emit('line', line);
|
||||
}
|
||||
byline(process.stdin).on('data', (line) => {
|
||||
const str = line.toString();
|
||||
this._buffer.push(str);
|
||||
this.emit('line', str);
|
||||
});
|
||||
} else {
|
||||
const tail = childProcess.spawn('tail', ['-n', options.buffer, '-F'].concat(path));
|
||||
|
|
Loading…
Reference in New Issue