diff options
author | Bennett <hello@vantezzen.io> | 2019-10-29 20:52:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-29 20:52:52 +0100 |
commit | 12fdb01d9c4c06c601b7cf62b1b2f170a0ca65c2 (patch) | |
tree | 3d03e94559724ec47f8c7e76accbbfd1abb80813 | |
parent | Merge pull request #161 from Makazzz/readme (diff) | |
parent | Revert to 93e718a (diff) | |
download | ferdium-app-12fdb01d9c4c06c601b7cf62b1b2f170a0ca65c2.tar.gz ferdium-app-12fdb01d9c4c06c601b7cf62b1b2f170a0ca65c2.tar.zst ferdium-app-12fdb01d9c4c06c601b7cf62b1b2f170a0ca65c2.zip |
Merge pull request #167 from Makazzz/portable-env
#87 Portable Directory working
-rw-r--r-- | src/config.js | 12 | ||||
-rw-r--r-- | src/index.js | 13 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/config.js b/src/config.js index 1db881d35..bd67aee6b 100644 --- a/src/config.js +++ b/src/config.js | |||
@@ -114,6 +114,18 @@ export const FILE_SYSTEM_SETTINGS_TYPES = [ | |||
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 | export const SERVER_NOT_LOADED = 'Ferdi::SERVER_NOT_LOADED'; | 115 | export const SERVER_NOT_LOADED = 'Ferdi::SERVER_NOT_LOADED'; |
116 | 116 | ||
117 | // Set app directory before loading user modules | ||
118 | if (process.env.FERDI_APPDATA_DIR != null) { | ||
119 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); | ||
120 | app.setPath('userData', path.join(app.getPath('appData'))); | ||
121 | } else if (process.env.PORTABLE_EXECUTABLE_DIR != null) { | ||
122 | app.setPath('appData', process.env.PORTABLE_EXECUTABLE_DIR, `${app.getName()}AppData`); | ||
123 | app.setPath('userData', path.join(app.getPath('appData'), `${app.getName()}AppData`)); | ||
124 | } else if (process.platform === 'win32') { | ||
125 | app.setPath('appData', process.env.APPDATA); | ||
126 | app.setPath('userData', path.join(app.getPath('appData'), app.getName())); | ||
127 | } | ||
128 | |||
117 | export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); | 129 | export const SETTINGS_PATH = path.join(app.getPath('userData'), 'config'); |
118 | 130 | ||
119 | // Replacing app.asar is not beautiful but unforunately necessary | 131 | // Replacing app.asar is not beautiful but unforunately necessary |
diff --git a/src/index.js b/src/index.js index 87aa6357b..3453b46f7 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -9,9 +9,16 @@ 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 | if (process.platform === 'win32') { | 12 | // Set app directory before loading user modules |
13 | app.setPath('appData', process.env.LOCALAPPDATA); | 13 | if (process.env.FERDI_APPDATA_DIR != null) { |
14 | app.setPath('userData', path.join(process.env.LOCALAPPDATA, app.getName())); | 14 | app.setPath('appData', process.env.FERDI_APPDATA_DIR); |
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())); | ||
15 | } | 22 | } |
16 | 23 | ||
17 | if (isDevMode) { | 24 | if (isDevMode) { |