Sha256: 292f0e40573f15105abb195877c497367a7bdaf0bc0c75e9b09df8dd3b8aac3c
Contents?: true
Size: 1.45 KB
Versions: 62
Compression:
Stored size: 1.45 KB
Contents
/* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ var Watchpack = require("watchpack"); function NewWatchingPlugin() { } module.exports = NewWatchingPlugin; NewWatchingPlugin.prototype.apply = function(compiler) { compiler.plugin("environment", function() { compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem); }); }; function NodeWatchFileSystem(inputFileSystem) { this.inputFileSystem = inputFileSystem; this.watcherOptions = { aggregateTimeout: 0 }; this.watcher = new Watchpack(this.watcherOptions); } NodeWatchFileSystem.prototype.watch = function watch(files, dirs, startTime, delay, callback, callbackUndelayed) { var oldWatcher = this.watcher; this.watcher = new Watchpack({ aggregateTimeout: delay }); var onChange = function() { callbackUndelayed(); }.bind(this); this.watcher.once("change", onChange); this.watcher.once("aggregated", function(changes) { if(this.inputFileSystem && this.inputFileSystem.purge) { this.inputFileSystem.purge(changes); } var times = this.watcher.getTimes(); callback(null, changes.filter(function(file) { return files.indexOf(file) >= 0; }).sort(), changes.filter(function(file) { return dirs.indexOf(file) >= 0; }).sort(), times, times); }.bind(this)); this.watcher.watch(files, dirs, startTime); if(oldWatcher) { oldWatcher.close(); } return { close: function() { this.watcher.pause(); }.bind(this) } };
Version data entries
62 entries across 62 versions & 1 rubygems