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

Version Path
smock-0.1.268 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.267 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.266 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.265 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.264 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.263 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.262 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.261 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.260 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.259 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.258 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.256 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.255 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.254 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.253 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.252 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.251 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.250 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.249 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.247 node_modules/webpack/lib/NewWatchingPlugin.js