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