Skip to content

Commit

Permalink
Try our own squirrel with logging
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinhenderson committed Nov 16, 2021
1 parent de66e09 commit afa6799
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eyecommander",
"productName": "EyeCommander",
"version": "1.0.18",
"version": "1.0.19",
"description": "Detect blinks and convert them to switch output",
"main": ".webpack/main",
"scripts": {
Expand Down
37 changes: 37 additions & 0 deletions src/backend/squirrel-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

var path = require('path');
var spawn = require('child_process').spawn;
var app = require('electron').app;
var logger = require('electron-log')

var run = function(args, done) {
var updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
logger.info('Spawning `%s` with args `%s`', updateExe, args);
spawn(updateExe, args, {
detached: true
}).on('close', done);
};

var check = function() {
if (process.platform === 'win32') {
var cmd = process.argv[1];
logger.info('processing squirrel command `%s`', cmd);
var target = path.basename(process.execPath);

if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
run(['--createShortcut=' + target + ''], app.quit);
return true;
}
if (cmd === '--squirrel-uninstall') {
run(['--removeShortcut=' + target + ''], app.quit);
return true;
}
if (cmd === '--squirrel-obsolete') {
app.quit();
return true;
}
}
return false;
};

module.exports = check();
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function isDebug() {
}

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require("electron-squirrel-startup")) {
if (require("./backend/squirrel-events")) {
// eslint-disable-line global-require
app.quit();
}
Expand Down

0 comments on commit afa6799

Please sign in to comment.