'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); };