Auto launch: don't open a terminal on MacOS
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
"dependencies": {
|
||||
"airplayer": "^2.0.0",
|
||||
"application-config": "^1.0.0",
|
||||
"auto-launch": "^4.0.0",
|
||||
"auto-launch": "^4.0.1",
|
||||
"bitfield": "^1.0.2",
|
||||
"chromecasts": "^1.8.0",
|
||||
"create-torrent": "^3.24.5",
|
||||
|
||||
@@ -5,23 +5,32 @@ module.exports = {
|
||||
|
||||
const config = require('../config')
|
||||
const AutoLaunch = require('auto-launch')
|
||||
const { app } = require('electron')
|
||||
|
||||
// On Mac, work around a bug in auto-launch where it opens a Terminal window
|
||||
// See https://github.com/Teamwork/node-auto-launch/issues/28#issuecomment-222194437
|
||||
const appPath = process.platform === 'darwin'
|
||||
? app.getPath('exe').replace(/\.app\/Content.*/, '.app')
|
||||
: undefined // Use the default
|
||||
|
||||
const appLauncher = new AutoLaunch({
|
||||
name: config.APP_NAME,
|
||||
path: appPath,
|
||||
isHidden: true
|
||||
})
|
||||
|
||||
function install () {
|
||||
return appLauncher.isEnabled()
|
||||
.then(enabled => {
|
||||
if (enabled) return
|
||||
return appLauncher.enable()
|
||||
})
|
||||
return appLauncher
|
||||
.isEnabled()
|
||||
.then(enabled => {
|
||||
if (!enabled) return appLauncher.enable()
|
||||
})
|
||||
}
|
||||
|
||||
function uninstall () {
|
||||
return appLauncher.isEnabled()
|
||||
.then(enabled => {
|
||||
if (enabled) return appLauncher.disable()
|
||||
})
|
||||
return appLauncher
|
||||
.isEnabled()
|
||||
.then(enabled => {
|
||||
if (enabled) return appLauncher.disable()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user