summary refs log tree commit diff
path: root/resources/app/node_modules/electron-squirrel-startup/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/app/node_modules/electron-squirrel-startup/index.js')
-rw-r--r--resources/app/node_modules/electron-squirrel-startup/index.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/resources/app/node_modules/electron-squirrel-startup/index.js b/resources/app/node_modules/electron-squirrel-startup/index.js
new file mode 100644
index 0000000..46a76fc
--- /dev/null
+++ b/resources/app/node_modules/electron-squirrel-startup/index.js
@@ -0,0 +1,36 @@
+var path = require('path');
+var spawn = require('child_process').spawn;
+var debug = require('debug')('electron-squirrel-startup');
+var app = require('electron').app;
+
+var run = function(args, done) {
+  var updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
+  debug('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];
+    debug('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();