Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
MichMich authored Feb 27, 2020
2 parents 6aeec81 + 2b2b07f commit 883c169
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
49 changes: 28 additions & 21 deletions modules/default/updatenotification/node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 883c169

Please sign in to comment.