aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Makazzz <makazzzpro@live.ca>2019-10-29 14:45:00 -0400
committerLibravatar Makazzz <makazzzpro@live.ca>2019-10-29 14:45:00 -0400
commit62f30ccd4c430213860da36d52de793cfcfd293a (patch)
tree0b790b68f59ca76d1719f21e46b705d22c933f05
parentAdd portable dir (diff)
downloadferdium-app-62f30ccd4c430213860da36d52de793cfcfd293a.tar.gz
ferdium-app-62f30ccd4c430213860da36d52de793cfcfd293a.tar.zst
ferdium-app-62f30ccd4c430213860da36d52de793cfcfd293a.zip
Creating function instead
-rw-r--r--src/config.js14
-rw-r--r--src/helpers/portable-helpers.js16
-rw-r--r--src/index.js14
3 files changed, 22 insertions, 22 deletions
diff --git a/src/config.js b/src/config.js
index a7389b8bc..33067fc9d 100644
--- a/src/config.js
+++ b/src/config.js
@@ -113,17 +113,9 @@ export const FILE_SYSTEM_SETTINGS_TYPES = [
113 113
114export const LOCAL_SERVER = 'You are using Ferdi without a server'; 114export const LOCAL_SERVER = 'You are using Ferdi without a server';
115 115
116// Set app directory before loading user modules 116import { portable } from './helpers/portable-helpers';
117if (process.env.FERDI_APPDATA_DIR != null) { 117
118 app.setPath('appData', process.env.FERDI_APPDATA_DIR); 118portable();
119 app.setPath('userData', path.join(app.getPath('appData')));
120} else if (process.env.PORTABLE_EXECUTABLE_DIR != null) {
121 app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.getName()}AppData`);
122 app.setPath('userData', path.join(app.getPath('appData'), `${app.getName()}AppData`));
123} else if (process.platform === 'win32') {
124 app.setPath('appData', process.env.APPDATA);
125 app.setPath('userData', path.join(app.getPath('appData'), app.getName()));
126}
127 119
128export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); 120export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config');
129 121
diff --git a/src/helpers/portable-helpers.js b/src/helpers/portable-helpers.js
new file mode 100644
index 000000000..60b7b91f1
--- /dev/null
+++ b/src/helpers/portable-helpers.js
@@ -0,0 +1,16 @@
1import { app } from 'electron';
2import path from 'path';
3
4// Set app directory before loading user modules
5export function portable() {
6 if (process.env.FERDI_APPDATA_DIR != null) {
7 app.setPath('appData', process.env.FERDI_APPDATA_DIR);
8 app.setPath('userData', path.join(app.getPath('appData')));
9 } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) {
10 app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.getName()}AppData`);
11 app.setPath('userData', path.join(app.getPath('appData'), `${app.getName()}AppData`));
12 } else if (process.platform === 'win32') {
13 app.setPath('appData', process.env.APPDATA);
14 app.setPath('userData', path.join(app.getPath('appData'), app.getName()));
15 }
16}
diff --git a/src/index.js b/src/index.js
index 3453b46f7..8d52e5396 100644
--- a/src/index.js
+++ b/src/index.js
@@ -9,17 +9,9 @@ import fs from 'fs-extra';
9import path from 'path'; 9import path from 'path';
10import windowStateKeeper from 'electron-window-state'; 10import windowStateKeeper from 'electron-window-state';
11 11
12// Set app directory before loading user modules 12import { portable } from './helpers/portable-helpers';
13if (process.env.FERDI_APPDATA_DIR != null) { 13
14 app.setPath('appData', process.env.FERDI_APPDATA_DIR); 14portable();
15 app.setPath('userData', path.join(app.getPath('appData')));
16} else if (process.env.PORTABLE_EXECUTABLE_DIR != null) {
17 app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.getName()}AppData`);
18 app.setPath('userData', path.join(app.getPath('appData'), `${app.getName()}AppData`));
19} else if (process.platform === 'win32') {
20 app.setPath('appData', process.env.APPDATA);
21 app.setPath('userData', path.join(app.getPath('appData'), app.getName()));
22}
23 15
24if (isDevMode) { 16if (isDevMode) {
25 app.setPath('userData', path.join(app.getPath('appData'), `${app.getName()}Dev`)); 17 app.setPath('userData', path.join(app.getPath('appData'), `${app.getName()}Dev`));