Merge pull request #162 from KiranNiranjan/ELECTRON-77

Electron-77 (User config)
This commit is contained in:
Vikas Shashidhar
2017-07-19 07:29:01 +05:30
committed by GitHub
3 changed files with 51 additions and 5 deletions
+1
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
+48 -4
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')();
@@ -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 = dirs.userConfig() + '/';
let globalConfigPath = process.argv[2];
let userName = process.env.USER;
childProcess.exec(`rsync -r "${globalConfigPath}" "${userConfigPath}" && chown -R "${userName}" "${userConfigPath}"`, {timeout: 60000}, (err) => {
if (err) {
reject(err);
}
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}"`, {timeout: 60000}, (err) => {
if (err) {
reject(err);
}
resolve();
});
});
}
function getUrlAndCreateMainWindow() {
// for dev env allow passing url argument
if (isDevEnv) {
+2 -1
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"