mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 20:22:53 +00:00
Check for module updates
This commit is contained in:
parent
6d6bf2df3a
commit
7329515a4d
@ -1,4 +1,7 @@
|
|||||||
var simpleGit = require("simple-git")(__dirname + "/../..");
|
var SimpleGit = require("simple-git");
|
||||||
|
var simpleGits = [];
|
||||||
|
var fs = require("fs");
|
||||||
|
var path = require("path");
|
||||||
var NodeHelper = require("node_helper");
|
var NodeHelper = require("node_helper");
|
||||||
|
|
||||||
module.exports = NodeHelper.create({
|
module.exports = NodeHelper.create({
|
||||||
@ -8,7 +11,19 @@ module.exports = NodeHelper.create({
|
|||||||
updateTimer: null,
|
updateTimer: null,
|
||||||
|
|
||||||
start: function () {
|
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))});
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
socketNotificationReceived: function (notification, payload) {
|
socketNotificationReceived: function (notification, payload) {
|
||||||
@ -20,10 +35,14 @@ module.exports = NodeHelper.create({
|
|||||||
|
|
||||||
preformFetch() {
|
preformFetch() {
|
||||||
var self = this;
|
var self = this;
|
||||||
simpleGit.fetch().status(function(err, data) {
|
|
||||||
if (!err) {
|
simpleGits.forEach(function(sg) {
|
||||||
self.sendSocketNotification("STATUS", data);
|
sg.git.fetch().status(function(err, data) {
|
||||||
}
|
data.module = sg.module;
|
||||||
|
if (!err) {
|
||||||
|
self.sendSocketNotification("STATUS", data);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.scheduleNextFetch(this.config.updateInterval);
|
this.scheduleNextFetch(this.config.updateInterval);
|
||||||
|
@ -49,7 +49,11 @@ Module.register("updatenotification", {
|
|||||||
message.appendChild(icon);
|
message.appendChild(icon);
|
||||||
|
|
||||||
var text = document.createElement("span");
|
var text = document.createElement("span");
|
||||||
text.innerHTML = this.translate("UPDATE_NOTIFICATION");
|
if (this.status.module == "default") {
|
||||||
|
text.innerHTML = this.translate("UPDATE_NOTIFICATION");
|
||||||
|
} else {
|
||||||
|
text.innerHTML = this.translate("UPDATE_NOTIFICATION_MODULE").replace("MODULE_NAME", this.status.module);
|
||||||
|
}
|
||||||
message.appendChild(text);
|
message.appendChild(text);
|
||||||
|
|
||||||
wrapper.appendChild(message);
|
wrapper.appendChild(message);
|
||||||
|
@ -29,5 +29,6 @@
|
|||||||
|
|
||||||
/* UPDATE INFO */
|
/* UPDATE INFO */
|
||||||
"UPDATE_NOTIFICATION": "MagicMirror² update available.",
|
"UPDATE_NOTIFICATION": "MagicMirror² update available.",
|
||||||
|
"UPDATE_NOTIFICATION_MODULE": "Update available for MODULE_NAME module.",
|
||||||
"UPDATE_INFO": "The current installation is COMMIT_COUNT behind on the BRANCH_NAME branch."
|
"UPDATE_INFO": "The current installation is COMMIT_COUNT behind on the BRANCH_NAME branch."
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,6 @@
|
|||||||
|
|
||||||
/* UPDATE INFO */
|
/* UPDATE INFO */
|
||||||
"UPDATE_NOTIFICATION": "MagicMirror² update beschikbaar.",
|
"UPDATE_NOTIFICATION": "MagicMirror² update beschikbaar.",
|
||||||
|
"UPDATE_NOTIFICATION_MODULE": "Update beschikbaar voor MODULE_NAME module.",
|
||||||
"UPDATE_INFO": "De huidige installatie loopt COMMIT_COUNT achter op de BRANCH_NAME branch."
|
"UPDATE_INFO": "De huidige installatie loopt COMMIT_COUNT achter op de BRANCH_NAME branch."
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user