use byline also for stdin

pull/102/head
Maciej Winnicki 2017-08-22 16:28:12 +02:00
parent bc8eb6cada
commit 756cbee2a5
No known key found for this signature in database
GPG Key ID: 035AA4FA2183ADFA
1 changed files with 4 additions and 7 deletions

View File

@ -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));