mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Merge pull request #1936 from buxxi/develop
Using promises to resolve which modules has a git remote
This commit is contained in:
commit
2b2b07f6b4
@ -30,6 +30,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Fix regression in currentweather module causing 'undefined' to show up when config.hideTemp is false
|
||||
- Fix FEELS translation for Croatian
|
||||
- Fixed weather tests [#1840](https://github.com/MichMich/MagicMirror/issues/1840)
|
||||
- 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).
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user