From fe77bc259b2392765f3990c90ff7d87768e30170 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Wed, 22 May 2019 13:41:19 +0530 Subject: [PATCH] ELECTRON-1247 (Remove old Symphony launch agent plist file) (#658) * ELECTRON-1247 - Remove old Symphony launch agent * ELECTRON-1247 - Rearrange dependency * ELECTRON-1247 - Remove config path logs * ELECTRON-1247 - Add log for removing old launch agent --- package.json | 1 + src/app/auto-launch-controller.ts | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/package.json b/package.json index bb4d7a31..2525c613 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "dependencies": { "archiver": "3.0.0", "async.map": "0.5.2", + "auto-launch": "5.0.5", "classnames": "2.2.6", "electron-dl": "1.14.0", "electron-fetch": "1.3.0", diff --git a/src/app/auto-launch-controller.ts b/src/app/auto-launch-controller.ts index 261d7596..f8750541 100644 --- a/src/app/auto-launch-controller.ts +++ b/src/app/auto-launch-controller.ts @@ -1,3 +1,4 @@ +import AutoLaunch = require('auto-launch'); import { app, LoginItemSettings } from 'electron'; import { isMac } from '../common/env'; @@ -57,6 +58,11 @@ class AutoLaunchController { const { launchOnStartup }: IConfig = config.getConfigFields([ 'launchOnStartup' ]); const { openAtLogin: isAutoLaunchEnabled }: LoginItemSettings = this.isAutoLaunchEnabled(); + if (isMac) { + // TODO: Remove this method in the future + await this.removeOldLaunchAgent(); + } + if (typeof launchOnStartup === 'boolean' && launchOnStartup) { if (!isAutoLaunchEnabled) { this.enableAutoLaunch(); @@ -67,6 +73,21 @@ class AutoLaunchController { this.disableAutoLaunch(); } } + + /** + * Removes old Symphony launch agent if exists + * + * @deprecated + */ + private async removeOldLaunchAgent(): Promise { + const autoLaunch = new AutoLaunch(props); + try { + await autoLaunch.disable(); + logger.info(`auto-launch-controller: Old Symphony launch agent has been successfully removed`); + } catch (e) { + logger.error(`auto-launch-controller: Old Symphony launch agent failed to remove ${e}`); + } + } } const autoLaunchInstance = new AutoLaunchController();