main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
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.slice(1) || 10 * 60 * 1000;
|
---|
8 | var log = require("./log");
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * @param {boolean=} fromUpdate true when called from update
|
---|
12 | */
|
---|
13 | var checkForUpdate = function checkForUpdate(fromUpdate) {
|
---|
14 | if (module.hot.status() === "idle") {
|
---|
15 | module.hot
|
---|
16 | .check(true)
|
---|
17 | .then(function (updatedModules) {
|
---|
18 | if (!updatedModules) {
|
---|
19 | if (fromUpdate) log("info", "[HMR] Update applied.");
|
---|
20 | return;
|
---|
21 | }
|
---|
22 | require("./log-apply-result")(updatedModules, updatedModules);
|
---|
23 | checkForUpdate(true);
|
---|
24 | })
|
---|
25 | .catch(function (err) {
|
---|
26 | var status = module.hot.status();
|
---|
27 | if (["abort", "fail"].indexOf(status) >= 0) {
|
---|
28 | log("warning", "[HMR] Cannot apply update.");
|
---|
29 | log("warning", "[HMR] " + log.formatError(err));
|
---|
30 | log("warning", "[HMR] You need to restart the application!");
|
---|
31 | } else {
|
---|
32 | log("warning", "[HMR] Update failed: " + log.formatError(err));
|
---|
33 | }
|
---|
34 | });
|
---|
35 | }
|
---|
36 | };
|
---|
37 | setInterval(checkForUpdate, hotPollInterval);
|
---|
38 | } else {
|
---|
39 | throw new Error("[HMR] Hot Module Replacement is disabled.");
|
---|
40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.