Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikax committed Oct 15, 2016
2 parents 5b65582 + bb9cd51 commit 30d3ab2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const https = require('https')
let websiteUrl = 'firebaseadmin.com'

let template = require('./js/menu')
if (process.platform === 'win32') require('./squirrel')
if (process.mas) app.setName('Firebase Admin')

// Keep a global reference of the window object, if you don't, the window will
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
"type": "file"
}
]
},
"linux": {
"target": "deb",
"maintainer": "[email protected]"
}
}
}
52 changes: 52 additions & 0 deletions squirrel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const app = require('electron').app

if (handleSquirrelEvent()) {
return
}

function handleSquirrelEvent() {
if (process.argv.length === 1) {
return false
}

const ChildProcess = require('child_process')
const path = require('path')
const appFolder = path.resolve(process.execPath, '..')
const rootAtomFolder = path.resolve(appFolder, '..')
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'))
const exeName = path.basename(process.execPath)

const spawn = function(command, args) {
let spawnedProcess, error

try {
spawnedProcess = ChildProcess.spawn(command, args, {detached: true})
} catch (error) {}

return spawnedProcess
}

const spawnUpdate = function(args) {
return spawn(updateDotExe, args)
}

const squirrelEvent = process.argv[1]
switch (squirrelEvent) {
case '--squirrel-install':
case '--squirrel-updated':
// Install desktop and start menu shortcuts
spawnUpdate(['--createShortcut', exeName])
setTimeout(app.quit, 1000)
return true

case '--squirrel-uninstall':
// Remove desktop and start menu shortcuts
spawnUpdate(['--removeShortcut', exeName])
setTimeout(app.quit, 1000)
return true

case '--squirrel-obsolete':
app.quit()
return true
}
}

0 comments on commit 30d3ab2

Please sign in to comment.