mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
274f4811f0
* ELECTRON-635: add support for auto launch custom path * ELECTRON-635 - autolaunch aip testing * ELECTRON-635 - Add quot * ELECTRON-635 - Escape quot * ELECTRON-635 - Escape quot * ELECTRON-635 - Fix escape auto launch path * ELECTRON-635 - Fix escape auto launch path * ELECTRON-635 - Fix escape auto launch path * ELECTRON-635 - add empty property to the AUTO_LAUNCH_PATH property * ELECTRON-635 - final fix for auto launch * ELECTRON-635 - Fix auto launch issue * ELECTRON-635 - Fix path escape * ELECTRON-635 - Fix first time launch * ELECTRON-635 - Mock app.getVersion * ELECTRON-635 - Fix per user app path
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
const AutoLaunch = require('auto-launch');
|
|
|
|
// Local Dependencies
|
|
const log = require('../log.js');
|
|
const logLevels = require('../enums/logLevels.js');
|
|
const { readConfigFileSync } = require('../config.js');
|
|
const { isMac } = require('../utils/misc.js');
|
|
|
|
const globalConfigData = readConfigFileSync();
|
|
const props = isMac ? {
|
|
name: 'Symphony',
|
|
mac: {
|
|
useLaunchAgent: true,
|
|
},
|
|
path: process.execPath,
|
|
} : {
|
|
name: 'Symphony',
|
|
path: getAutoLaunchPath() || process.execPath,
|
|
};
|
|
|
|
class AutoLaunchController extends AutoLaunch {
|
|
|
|
constructor(opts) {
|
|
super(opts);
|
|
}
|
|
|
|
/**
|
|
* Enable auto launch
|
|
* @return {Promise<void>}
|
|
*/
|
|
enableAutoLaunch() {
|
|
log.send(logLevels.INFO, `Enabling auto launch!`);
|
|
return this.enable();
|
|
}
|
|
|
|
/**
|
|
* Disable auto launch
|
|
* @return {Promise<void>}
|
|
*/
|
|
disableAutoLaunch() {
|
|
log.send(logLevels.INFO, `Disabling auto launch!`);
|
|
return this.disable();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Replace forward slash in the path to backward slash
|
|
* @return {any}
|
|
*/
|
|
function getAutoLaunchPath() {
|
|
const autoLaunchPath = globalConfigData && globalConfigData.autoLaunchPath || null;
|
|
return autoLaunchPath ? autoLaunchPath.replace(/\//g, '\\') : null;
|
|
}
|
|
|
|
const autoLaunchInstance = new AutoLaunchController(props);
|
|
|
|
module.exports = {
|
|
enable: autoLaunchInstance.enableAutoLaunch.bind(autoLaunchInstance),
|
|
disable: autoLaunchInstance.disableAutoLaunch.bind(autoLaunchInstance)
|
|
}; |