Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PORTABLE_EXECUTABLE_DIR to determine if we're in portable mode #1349

Merged
merged 1 commit into from
Jan 15, 2020

Conversation

Jikstra
Copy link
Contributor

@Jikstra Jikstra commented Jan 14, 2020

Fixes #1315

-const fileContent = fs.readFileSync(appConfig, 'utf-8')
-  .replace(
-    /const portable = (?:false|true)/,
-    `const portable = ${JSON.stringify(action === 'do')}`
-  )
-
-fs.writeFileSync(appConfig, fileContent)
diff --git a/package.json b/package.json
index 81f7a532..38a5f8be 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
     "pack": "npm run build && electron-builder --dir",
     "dist-ci": "version-unchanged || npm run dist",
     "dist": "electron-builder --publish=onTagOrDraft",
-    "dist-portable": "node bin/prepare-build-portable && electron-builder --win portable --linux AppImage && node bin/prepare-build-portable undo",
+    "dist-portable": "electron-builder --win portable --linux AppImage",
     "build": "npm run build-css && npm run build-js && npm run build-translations",
     "build-css": "node-sass scss/manifest.scss static/main.css",
     "build-js": "webpack --mode=development --progress --profile --colors",
diff --git a/src/application-config.js b/src/application-config.js
index be2a08f2..725068f1 100644
--- a/src/application-config.js
+++ b/src/application-config.js
@@ -1,14 +1,12 @@
 const appConfig = require('application-config')('DeltaChat')
 const path = require('path')

-const portable = false
-
 if (process.env.TEST_DIR) {
   appConfig.filePath = path.join(process.env.TEST_DIR, 'config.json')
-} else if (portable) {
+} else if (process.env.PORTABLE_EXECUTABLE_DIR) {
   /* ignore-console-log */
-  console.log('Running in Portable Mode', process.cwd())
-  appConfig.filePath = path.join(process.cwd(), 'DeltaChatData', 'config.json')
+  console.log('Running in Portable Mode', process.env.PORTABLE_EXECUTABLE_DIR)
+  appConfig.filePath = path.join(process.env.PORTABLE_EXECUTABLE_DIR, 'DeltaChatData', 'config.json')
 }

 module.exports = Object.freeze(appConfig)
Copy link
Member

@Simon-Laux Simon-Laux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and works as expected in wine

@Simon-Laux Simon-Laux merged commit 1bf33e5 into master Jan 15, 2020
@Simon-Laux Simon-Laux deleted the fix_win_portable branch January 15, 2020 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Portable windows shouldn't use home/config folder but the folder where the .exe lays in
3 participants