Windows: create desktop/start menu shortcuts on install/update

This commit is contained in:
Feross Aboukhadijeh
2016-03-25 01:39:44 -07:00
parent 78f08487c4
commit 8bba565609
3 changed files with 30 additions and 22 deletions

View File

@@ -16,10 +16,9 @@ var shouldQuit = false
var argv = sliceArgv(process.argv)
if (process.platform === 'win32') {
shouldQuit = squirrelWin32.handleArgv(argv[0])
// Remove any --squirrel-xxxx arguments
argv.shift()
shouldQuit = squirrelWin32.handleEvent(argv[0])
argv.shift() // Remove any --squirrel-xxxx arguments
// app.setAppUserModelId('com.squirrel.WebTorrent.WebTorrent')
}
if (!shouldQuit) {

View File

@@ -1,34 +1,33 @@
module.exports = {
handleArgv
handleEvent
}
var cp = require('child_process')
var electron = require('electron')
var path = require('path')
var app = electron.app
var config = require('../config')
var handlers = require('./handlers')
function handleArgv (cmd) {
if (cmd === '--squirrel-install') {
// App was just installed.
handlers.init()
function handleEvent (cmd) {
if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
// App was installed/updated. (Called on new version of app.)
// TODO:
// - Install desktop and start menu shortcuts
// - Add explorer context menus
// Install protocol/file handlers, desktop/start menu shortcuts.
handlers.init()
createShortcuts()
// Ensure user sees install splash screen so they realize that Setup.exe actually
// installed an application and isn't the application itself.
setTimeout(function () {
if (cmd === '--squirrel-install') {
setTimeout(function () {
app.quit()
}, 5000)
} else {
app.quit()
}, 5000)
return true
}
if (cmd === '--squirrel-updated') {
// App was just updated. (Called on new version of app.)
handlers.init()
app.quit()
}
return true
}
@@ -54,3 +53,13 @@ function handleArgv (cmd) {
return false
}
function createShortcuts () {
var updateExe = path.join(process.execPath, '..', 'Update.exe')
var args = [
'--createShortcut="' + config.APP_NAME + '.exe"',
'--shortcut-locations="Desktop,StartMenu,Startup"',
'--process-start-args="--autostart"'
]
cp.execSync(updateExe + args.join(' '))
}

View File

@@ -1,5 +1,5 @@
{
"name": "webtorrent-app",
"name": "WebTorrent",
"description": "WebTorrent, the streaming torrent client. For OS X, Windows, and Linux.",
"version": "0.0.1",
"author": {