Created
June 24, 2018 05:01
-
-
Save boid-com/e6348d0dbde4e6633ceb67bbb846ae54 to your computer and use it in GitHub Desktop.
Squirrel shortcut fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var spawn = require('child_process').spawn; | |
var debug = require('debug')('electron-squirrel-startup'); | |
var app = require('electron').app; | |
var appInfo = require('../package.json') | |
console.log(path.resolve(path.dirname(process.execPath),'..',`app-` + appInfo.version,path.basename(process.execPath))) | |
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.resolve(path.dirname(process.execPath),'..',`app-` + appInfo.version,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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment