diff --git a/CHANGELOG.md b/CHANGELOG.md index 16babe83d1..ce90241c12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Fix FEELS translation for Croatian - Fixed weather tests [#1840](https://github.com/MichMich/MagicMirror/issues/1840) - Fixed Socket.io can't be used with Reverse Proxy in serveronly mode [#1934](https://github.com/MichMich/MagicMirror/issues/1934) +- Fix update checking skipping 3rd party modules the first time ### Updated - Remove documentation from core repository and link to new dedicated docs site: [docs.magicmirror.builders](https://docs.magicmirror.builders). diff --git a/modules/default/updatenotification/node_helper.js b/modules/default/updatenotification/node_helper.js index 818697c0d7..4386b146d0 100644 --- a/modules/default/updatenotification/node_helper.js +++ b/modules/default/updatenotification/node_helper.js @@ -18,37 +18,30 @@ module.exports = NodeHelper.create({ configureModules: function(modules) { // Push MagicMirror itself , biggest chance it'll show up last in UI and isn't overwritten - // others will be added in front, asynchronously + // others will be added in front + // this method returns promises so we can't wait for every one to resolve before continuing simpleGits.push({"module": "default", "git": SimpleGit(path.normalize(__dirname + "/../../../"))}); + var promises = []; + for (moduleName in modules) { if (!this.ignoreUpdateChecking(moduleName)) { // Default modules are included in the main MagicMirror repo var moduleFolder = path.normalize(__dirname + "/../../" + moduleName); - var stat; try { //console.log("checking git for module="+moduleName) - stat = fs.statSync(path.join(moduleFolder, ".git")); + let stat = fs.statSync(path.join(moduleFolder, ".git")); + promises.push(this.resolveRemote(moduleName, moduleFolder)); } catch(err) { // Error when directory .git doesn't exist // This module is not managed with git, skip continue; } - - var res = function(mn, mf) { - var git = SimpleGit(mf); - git.getRemotes(true, function(err, remotes) { - if (remotes.length < 1 || remotes[0].name.length < 1) { - // No valid remote for folder, skip - return; - } - // Folder has .git and has at least one git remote, watch this folder - simpleGits.unshift({"module": mn, "git": git}); - }); - }(moduleName, moduleFolder); } } + + return Promise.all(promises); }, socketNotificationReceived: function (notification, payload) { @@ -58,19 +51,33 @@ module.exports = NodeHelper.create({ // if this is the 1st time thru the update check process if (!this.updateProcessStarted) { this.updateProcessStarted = true; - this.configureModules(payload); - this.performFetch(); + this.configureModules(payload).then(() => this.performFetch()); } } }, - performFetch() { + resolveRemote: function(moduleName, moduleFolder) { + return new Promise((resolve, reject) => { + var git = SimpleGit(moduleFolder); + git.getRemotes(true, (err, remotes) => { + if (remotes.length < 1 || remotes[0].name.length < 1) { + // No valid remote for folder, skip + return resolve(); + } + // Folder has .git and has at least one git remote, watch this folder + simpleGits.unshift({"module": moduleName, "git": git}); + resolve(); + }); + }); + }, + + performFetch: function() { var self = this; - simpleGits.forEach(function(sg) { - sg.git.fetch().status(function(err, data) { + simpleGits.forEach((sg) => { + sg.git.fetch().status((err, data) => { data.module = sg.module; if (!err) { - sg.git.log({"-1": null}, function(err, data2) { + sg.git.log({"-1": null}, (err, data2) => { if (!err && data2.latest && "hash" in data2.latest) { data.hash = data2.latest.hash; self.sendSocketNotification("STATUS", data);