Electron-77 - Implemented method to update user config

This commit is contained in:
Kiran Niranjan 2017-07-13 01:27:21 +05:30 committed by Kiran Niranjan
parent 717e17f184
commit e146a95620
3 changed files with 51 additions and 5 deletions

View File

@ -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

View File

@ -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')();
@ -95,6 +99,15 @@ function setupThenOpenMainWindow() {
if (!isMac && hasInstallFlag) {
getConfigField('launchOnStartup')
.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) {

View File

@ -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"