Files
tankz/tasks/tail.js
2017-12-17 22:29:16 +03:00

26 lines
614 B
JavaScript
Executable File

'use strict';
const through = require('through2');
const gutil = require('gulp-util');
const col = gutil.colors;
const Tail = require('tail').Tail;
module.exports = (handler) => {
let stream = null;
let tail = null;
const bufferContents = (file, enc, callback) => {
tail = new Tail(file.path);
tail.on("line", handler);
callback();
};
const endStream = (callback) => {
if (tail) {
tail.unwatch();
tail = null;
}
callback();
};
return stream = through.obj(bufferContents, endStream);
};