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.228 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.227 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.226 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.225 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.224 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.9 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.223 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.222 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.221 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.220 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.219 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.218 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.217 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.216 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.215 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.214 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.213 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.212 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.211 node_modules/webpack/lib/NewWatchingPlugin.js
smock-0.1.210 node_modules/webpack/lib/NewWatchingPlugin.js