Auto launch: don't open a terminal on MacOS

This commit is contained in:
DC
2016-09-09 18:10:47 -07:00
parent 3e85289318
commit 61caa90901
2 changed files with 19 additions and 10 deletions

View File

@@ -16,7 +16,7 @@
"dependencies": { "dependencies": {
"airplayer": "^2.0.0", "airplayer": "^2.0.0",
"application-config": "^1.0.0", "application-config": "^1.0.0",
"auto-launch": "^4.0.0", "auto-launch": "^4.0.1",
"bitfield": "^1.0.2", "bitfield": "^1.0.2",
"chromecasts": "^1.8.0", "chromecasts": "^1.8.0",
"create-torrent": "^3.24.5", "create-torrent": "^3.24.5",

View File

@@ -5,23 +5,32 @@ module.exports = {
const config = require('../config') const config = require('../config')
const AutoLaunch = require('auto-launch') 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({ const appLauncher = new AutoLaunch({
name: config.APP_NAME, name: config.APP_NAME,
path: appPath,
isHidden: true isHidden: true
}) })
function install () { function install () {
return appLauncher.isEnabled() return appLauncher
.then(enabled => { .isEnabled()
if (enabled) return .then(enabled => {
return appLauncher.enable() if (!enabled) return appLauncher.enable()
}) })
} }
function uninstall () { function uninstall () {
return appLauncher.isEnabled() return appLauncher
.then(enabled => { .isEnabled()
if (enabled) return appLauncher.disable() .then(enabled => {
}) if (enabled) return appLauncher.disable()
})
} }