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
This commit is contained in:
Kiran Niranjan 2019-05-22 13:41:19 +05:30 committed by Vishwas Shashidhar
parent fa79bde23a
commit fe77bc259b
2 changed files with 22 additions and 0 deletions

View File

@ -111,6 +111,7 @@
"dependencies": { "dependencies": {
"archiver": "3.0.0", "archiver": "3.0.0",
"async.map": "0.5.2", "async.map": "0.5.2",
"auto-launch": "5.0.5",
"classnames": "2.2.6", "classnames": "2.2.6",
"electron-dl": "1.14.0", "electron-dl": "1.14.0",
"electron-fetch": "1.3.0", "electron-fetch": "1.3.0",

View File

@ -1,3 +1,4 @@
import AutoLaunch = require('auto-launch');
import { app, LoginItemSettings } from 'electron'; import { app, LoginItemSettings } from 'electron';
import { isMac } from '../common/env'; import { isMac } from '../common/env';
@ -57,6 +58,11 @@ class AutoLaunchController {
const { launchOnStartup }: IConfig = config.getConfigFields([ 'launchOnStartup' ]); const { launchOnStartup }: IConfig = config.getConfigFields([ 'launchOnStartup' ]);
const { openAtLogin: isAutoLaunchEnabled }: LoginItemSettings = this.isAutoLaunchEnabled(); const { openAtLogin: isAutoLaunchEnabled }: LoginItemSettings = this.isAutoLaunchEnabled();
if (isMac) {
// TODO: Remove this method in the future
await this.removeOldLaunchAgent();
}
if (typeof launchOnStartup === 'boolean' && launchOnStartup) { if (typeof launchOnStartup === 'boolean' && launchOnStartup) {
if (!isAutoLaunchEnabled) { if (!isAutoLaunchEnabled) {
this.enableAutoLaunch(); this.enableAutoLaunch();
@ -67,6 +73,21 @@ class AutoLaunchController {
this.disableAutoLaunch(); this.disableAutoLaunch();
} }
} }
/**
* Removes old Symphony launch agent if exists
*
* @deprecated
*/
private async removeOldLaunchAgent(): Promise<void> {
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(); const autoLaunchInstance = new AutoLaunchController();