|
@@ -1,8 +1,11 @@
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
|
|
+const autoUpdater = require('auto-updater');
|
|
|
|
+const os = require('os').platform();
|
|
//Relative to index.html not app.js
|
|
//Relative to index.html not app.js
|
|
const SerialScanner = require("../back-end/serial_scanner");
|
|
const SerialScanner = require("../back-end/serial_scanner");
|
|
const PortSelect = require("./js/port_select");
|
|
const PortSelect = require("./js/port_select");
|
|
|
|
+const packageInfo = require('./package.json');
|
|
|
|
|
|
function $(id) { return document.getElementById(id); }
|
|
function $(id) { return document.getElementById(id); }
|
|
|
|
|
|
@@ -35,6 +38,10 @@ serialScanner.on("deviceRemoved", (port ) => {
|
|
|
|
|
|
serialScanner.on("error", onError);
|
|
serialScanner.on("error", onError);
|
|
|
|
|
|
|
|
+autoUpdater.on("checking-for-update", () => {
|
|
|
|
+ new Notification("Checking for updates");
|
|
|
|
+});
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Updates UI to say it's ready
|
|
* Updates UI to say it's ready
|
|
*/
|
|
*/
|
|
@@ -63,12 +70,19 @@ function onError(error){
|
|
appStatus.textContent = error.message;
|
|
appStatus.textContent = error.message;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function initUpdater() {
|
|
|
|
+ let updateFeed = `http://localhost:3000/updates/${packageInfo.name}/latest`;
|
|
|
|
+ autoUpdater.setFeedURL(updateFeed + '?v=' + packageInfo.version);
|
|
|
|
+ autoUpdater.checkForUpdates();
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Sets up UI
|
|
* Sets up UI
|
|
*/
|
|
*/
|
|
function init() {
|
|
function init() {
|
|
serialScanner.scan();
|
|
serialScanner.scan();
|
|
setInterval(serialScanner.checkForChanges.bind(serialScanner), pollTime);
|
|
setInterval(serialScanner.checkForChanges.bind(serialScanner), pollTime);
|
|
|
|
+ initUpdater();
|
|
}
|
|
}
|
|
|
|
|
|
init();
|
|
init();
|