Projekt

Obecné

Profil

Stáhnout (1.12 KB) Statistiky
| Větev: | Revize:
1
/*
2
	MIT License http://www.opensource.org/licenses/mit-license.php
3
	Author Tobias Koppers @sokra
4
*/
5
/*globals __resourceQuery */
6
if (module.hot) {
7
	var hotPollInterval = +__resourceQuery.substr(1) || 10 * 60 * 1000;
8
	var log = require("./log");
9

    
10
	var checkForUpdate = function checkForUpdate(fromUpdate) {
11
		if (module.hot.status() === "idle") {
12
			module.hot
13
				.check(true)
14
				.then(function(updatedModules) {
15
					if (!updatedModules) {
16
						if (fromUpdate) log("info", "[HMR] Update applied.");
17
						return;
18
					}
19
					require("./log-apply-result")(updatedModules, updatedModules);
20
					checkForUpdate(true);
21
				})
22
				.catch(function(err) {
23
					var status = module.hot.status();
24
					if (["abort", "fail"].indexOf(status) >= 0) {
25
						log("warning", "[HMR] Cannot apply update.");
26
						log("warning", "[HMR] " + log.formatError(err));
27
						log("warning", "[HMR] You need to restart the application!");
28
					} else {
29
						log("warning", "[HMR] Update failed: " + log.formatError(err));
30
					}
31
				});
32
		}
33
	};
34
	setInterval(checkForUpdate, hotPollInterval);
35
} else {
36
	throw new Error("[HMR] Hot Module Replacement is disabled.");
37
}
(6-6/7)