mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
Electron-77 - Implemented method to update user config
This commit is contained in:
parent
717e17f184
commit
e146a95620
@ -46,6 +46,7 @@ rm -f $tempFilePath
|
||||
|
||||
## For launching symphony with sandbox enabled, create a shell script that is used as the launch point for the app
|
||||
EXEC_PATH=$installPath/Symphony.app/Contents/MacOS
|
||||
exec $EXEC_PATH/Symphony --install $newPath
|
||||
mv $EXEC_PATH/Symphony $EXEC_PATH/Symphony-bin
|
||||
cat > $EXEC_PATH/Symphony << EOT
|
||||
#!/bin/sh
|
||||
|
52
js/main.js
52
js/main.js
@ -9,7 +9,11 @@ const urlParser = require('url');
|
||||
const { getConfigField } = require('./config.js');
|
||||
const { isMac, isDevEnv } = require('./utils/misc.js');
|
||||
const protocolHandler = require('./protocolHandler');
|
||||
const getCmdLineArg = require('./utils/getCmdLineArg.js')
|
||||
const getCmdLineArg = require('./utils/getCmdLineArg.js');
|
||||
const childProcess = require('child_process');
|
||||
const path = require('path');
|
||||
const AppDirectory = require('appdirectory');
|
||||
const dirs = new AppDirectory('Symphony');
|
||||
|
||||
require('electron-dl')();
|
||||
|
||||
@ -94,9 +98,18 @@ function setupThenOpenMainWindow() {
|
||||
let hasInstallFlag = getCmdLineArg(process.argv, '--install', true);
|
||||
if (!isMac && hasInstallFlag) {
|
||||
getConfigField('launchOnStartup')
|
||||
.then(setStartup)
|
||||
.then(app.quit)
|
||||
.catch(app.quit);
|
||||
.then(setStartup)
|
||||
.then(updateUserConfigWin)
|
||||
.then(app.quit)
|
||||
.catch(app.quit);
|
||||
return;
|
||||
}
|
||||
|
||||
// allows mac installer to overwrite user config
|
||||
if (isMac && hasInstallFlag) {
|
||||
updateUserConfigMac()
|
||||
.then(app.quit)
|
||||
.catch(app.quit);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -118,6 +131,37 @@ function setStartup(lStartup){
|
||||
});
|
||||
}
|
||||
|
||||
// Method to overwrite user config on mac installer
|
||||
function updateUserConfigMac() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let userConfigPath = process.env.HOME + '/Library/Application Support/Symphony/';
|
||||
let globalConfigPath = process.argv[2];
|
||||
let userName = process.env.USER;
|
||||
|
||||
childProcess.exec(`rsync -r "${globalConfigPath}" "${userConfigPath}" && chown -R "${userName}" "${userConfigPath}"`, (error, stdout) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Method to overwrite user config on windows installer
|
||||
function updateUserConfigWin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let userConfigPath = app.getPath('userData');
|
||||
let globalConfigPath = path.join(__dirname, '..', '..', '..', 'config/Symphony.config');
|
||||
|
||||
childProcess.exec(`echo D|xcopy /y /e /s /c "${globalConfigPath}" "${userConfigPath}"`, (err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getUrlAndCreateMainWindow() {
|
||||
// for dev env allow passing url argument
|
||||
if (isDevEnv) {
|
||||
|
@ -92,7 +92,8 @@
|
||||
"keymirror": "0.1.1",
|
||||
"winreg": "^1.2.3",
|
||||
"electron-dl": "^1.9.0",
|
||||
"filesize": "^3.5.10"
|
||||
"filesize": "^3.5.10",
|
||||
"appdirectory": "^0.1.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"screen-snippet": "git+https://github.com/symphonyoss/ScreenSnippet.git#v1.0.1"
|
||||
|
Loading…
Reference in New Issue
Block a user