diff options
-rw-r--r-- | src/config.js | 14 | ||||
-rw-r--r-- | src/helpers/portable-helpers.js | 16 | ||||
-rw-r--r-- | src/index.js | 14 |
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 | ||
114 | export const LOCAL_SERVER = 'You are using Ferdi without a server'; | 114 | export const LOCAL_SERVER = 'You are using Ferdi without a server'; |
115 | 115 | ||
116 | // Set app directory before loading user modules | 116 | import { portable } from './helpers/portable-helpers'; |
117 | if (process.env.FERDI_APPDATA_DIR != null) { | 117 | |
118 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); | 118 | portable(); |
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 | ||
128 | export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); | 120 | export 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 @@ | |||
1 | import { app } from 'electron'; | ||
2 | import path from 'path'; | ||
3 | |||
4 | // Set app directory before loading user modules | ||
5 | export 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'; | |||
9 | import path from 'path'; | 9 | import path from 'path'; |
10 | import windowStateKeeper from 'electron-window-state'; | 10 | import windowStateKeeper from 'electron-window-state'; |
11 | 11 | ||
12 | // Set app directory before loading user modules | 12 | import { portable } from './helpers/portable-helpers'; |
13 | if (process.env.FERDI_APPDATA_DIR != null) { | 13 | |
14 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); | 14 | portable(); |
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 | ||
24 | if (isDevMode) { | 16 | if (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`)); |