Skip to content

Commit 30d3ab2

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/dev-1'
2 parents 5b65582 + bb9cd51 commit 30d3ab2

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const https = require('https')
77
let websiteUrl = 'firebaseadmin.com'
88

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

1213
// Keep a global reference of the window object, if you don't, the window will

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
"type": "file"
7474
}
7575
]
76+
},
77+
"linux": {
78+
"target": "deb",
79+
"maintainer": "dev@codefoxes.com"
7680
}
7781
}
7882
}

squirrel.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const app = require('electron').app
2+
3+
if (handleSquirrelEvent()) {
4+
return
5+
}
6+
7+
function handleSquirrelEvent() {
8+
if (process.argv.length === 1) {
9+
return false
10+
}
11+
12+
const ChildProcess = require('child_process')
13+
const path = require('path')
14+
const appFolder = path.resolve(process.execPath, '..')
15+
const rootAtomFolder = path.resolve(appFolder, '..')
16+
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'))
17+
const exeName = path.basename(process.execPath)
18+
19+
const spawn = function(command, args) {
20+
let spawnedProcess, error
21+
22+
try {
23+
spawnedProcess = ChildProcess.spawn(command, args, {detached: true})
24+
} catch (error) {}
25+
26+
return spawnedProcess
27+
}
28+
29+
const spawnUpdate = function(args) {
30+
return spawn(updateDotExe, args)
31+
}
32+
33+
const squirrelEvent = process.argv[1]
34+
switch (squirrelEvent) {
35+
case '--squirrel-install':
36+
case '--squirrel-updated':
37+
// Install desktop and start menu shortcuts
38+
spawnUpdate(['--createShortcut', exeName])
39+
setTimeout(app.quit, 1000)
40+
return true
41+
42+
case '--squirrel-uninstall':
43+
// Remove desktop and start menu shortcuts
44+
spawnUpdate(['--removeShortcut', exeName])
45+
setTimeout(app.quit, 1000)
46+
return true
47+
48+
case '--squirrel-obsolete':
49+
app.quit()
50+
return true
51+
}
52+
}

0 commit comments

Comments
 (0)