| 10 | * @param {boolean=} fromUpdate true when called from update |
| 11 | */ |
| 12 | var checkForUpdate = function checkForUpdate(fromUpdate) { |
| 13 | module.hot |
| 14 | .check() |
| 15 | .then(function (updatedModules) { |
| 16 | if (!updatedModules) { |
| 17 | if (fromUpdate) log("info", "[HMR] Update applied."); |
| 18 | else log("warning", "[HMR] Cannot find update."); |
| 19 | return; |
| 20 | } |
| 21 | |
| 22 | return module.hot |
| 23 | .apply({ |
| 24 | ignoreUnaccepted: true, |
| 25 | onUnaccepted: function (data) { |
| 26 | log( |
| 27 | "warning", |
| 28 | "Ignored an update to unaccepted module " + |
| 29 | data.chain.join(" -> ") |
| 30 | ); |
| 31 | } |
| 32 | }) |
| 33 | .then(function (renewedModules) { |
| 34 | require("./log-apply-result")(updatedModules, renewedModules); |
| 35 | |
| 36 | checkForUpdate(true); |
| 37 | return null; |
| 38 | }); |
| 39 | }) |
| 40 | .catch(function (err) { |
| 41 | var status = module.hot.status(); |
| 42 | if (["abort", "fail"].indexOf(status) >= 0) { |
| 43 | log("warning", "[HMR] Cannot apply update."); |
| 44 | log("warning", "[HMR] " + log.formatError(err)); |
| 45 | log("warning", "[HMR] You need to restart the application!"); |
| 46 | } else { |
| 47 | log("warning", "[HMR] Update failed: " + (err.stack || err.message)); |
| 48 | } |
| 49 | }); |
| 50 | }; |
| 51 | |
| 52 | process.on(__resourceQuery.slice(1) || "SIGUSR2", function () { |
| 53 | if (module.hot.status() !== "idle") { |