mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Check updates for configured modules only
This commit is contained in:
parent
0f44fd2290
commit
482dd4db76
@ -2,6 +2,7 @@ var SimpleGit = require("simple-git");
|
||||
var simpleGits = [];
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var defaultModules = require(__dirname + "/../defaultmodules.js");
|
||||
var NodeHelper = require("node_helper");
|
||||
|
||||
module.exports = NodeHelper.create({
|
||||
@ -11,24 +12,36 @@ module.exports = NodeHelper.create({
|
||||
updateTimer: null,
|
||||
|
||||
start: function () {
|
||||
var srcdir = __dirname + "/../../";
|
||||
fs.readdir(srcdir, function(err, names) {
|
||||
if (err) {
|
||||
console.error("Error reading dir " + srcdir + ": " + err);
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
names.filter(function(name) {
|
||||
return fs.statSync(path.join(srcdir, name)).isDirectory() && name != "node_modules";
|
||||
}).forEach(function(name) {
|
||||
simpleGits.push({"module": name, "git": SimpleGit(path.join(srcdir, name))});
|
||||
});
|
||||
});
|
||||
configureModules: function(modules) {
|
||||
for (moduleName in modules) {
|
||||
if (defaultModules.indexOf(moduleName) < 0) {
|
||||
// Default modules are included in the main MagicMirror repo
|
||||
var moduleFolder = path.normalize(__dirname + "/../../" + moduleName);
|
||||
|
||||
var stat;
|
||||
try {
|
||||
stat = fs.statSync(path.join(moduleFolder, '.git'));
|
||||
} catch(err) {
|
||||
// Error when directory .git doesn't exist
|
||||
// This module is not managed with git, skip
|
||||
continue;
|
||||
}
|
||||
|
||||
simpleGits.push({"module": moduleName, "git": SimpleGit(moduleFolder)});
|
||||
}
|
||||
}
|
||||
|
||||
// Push MagicMirror itself last, biggest chance it'll show up last in UI and isn't overwritten
|
||||
simpleGits.push({"module": "default", "git": SimpleGit(path.normalize(__dirname + "/../../../"))});
|
||||
},
|
||||
|
||||
socketNotificationReceived: function (notification, payload) {
|
||||
if (notification === "CONFIG") {
|
||||
this.config = payload;
|
||||
} else if(notification === "MODULES") {
|
||||
this.configureModules(payload);
|
||||
this.preformFetch();
|
||||
}
|
||||
},
|
||||
|
@ -1,7 +1,5 @@
|
||||
Module.register("updatenotification", {
|
||||
|
||||
|
||||
|
||||
defaults: {
|
||||
updateInterval: 10 * 60 * 1000, // every 10 minutes
|
||||
},
|
||||
@ -10,12 +8,13 @@ Module.register("updatenotification", {
|
||||
|
||||
start: function () {
|
||||
Log.log("Start updatenotification");
|
||||
|
||||
|
||||
},
|
||||
|
||||
notificationReceived: function(notification, payload, sender) {
|
||||
if (notification === "DOM_OBJECTS_CREATED") {
|
||||
this.sendSocketNotification("CONFIG", this.config);
|
||||
this.sendSocketNotification("MODULES", Module.definitions);
|
||||
this.hide(0,{lockString: self.identifier});
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user