Skip to content

TagSpaces is an offline, open source, document manager with tagging support

implementing portable desktop mode

Ilian Sapundshieva6cf2475faab
diff --git a/.gitignore b/.gitignore
index 9d75bd153..fc30cc952 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,3 +65,5 @@ app/THIRD-PARTY.html
app/THIRD-PARTY.txt
scripts/setuppro.js
+
+tsprofile
diff --git a/app/main.dev.js b/app/main.dev.js
index ff5ab3f71..cd926a20c 100644
--- a/app/main.dev.js
+++ b/app/main.dev.js
@@ -32,6 +32,30 @@ if (process.env.NODE_ENV === 'production') {
console.timeEnd = () => {};
}
+let debugMode;
+let startupFilePath;
+let portableMode;
+
+process.argv.forEach((arg, count) => {
+ if (arg.toLowerCase() === '-d' || arg.toLowerCase() === '--debug') {
+ debugMode = true;
+ } else if (arg.toLowerCase() === '-p' || arg.toLowerCase() === '--portable') {
+ app.setPath('userData', process.cwd() + '/tsprofile'); // making the app portable
+ portableMode = true;
+ } else if (arg.indexOf('-psn') >= 0) { // ignoring the -psn process serial number parameter on MacOS by double click
+ arg = '';
+ } else if (arg === '.' || count === 0) { // ignoring the first argument
+ // Ignore these argument
+ } else if (arg.length > 2) {
+ // console.warn('Opening file: ' + arg);
+ startupFilePath = arg;
+ }
+
+ if (portableMode) {
+ startupFilePath = undefined;
+ }
+});
+
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
require('electron-debug')();
const p = path.join(__dirname, '..', 'app', 'node_modules');
diff --git a/package.json b/package.json
index 704ef1313..0178cbf63 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"build-renderer": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.prod.js --progress --profile --colors",
"build-worker": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.worker.prod.js --progress --profile --colors",
"start": "cross-env NODE_ENV=production electron ./app/",
+ "start-portable": "cross-env NODE_ENV=production electron ./app/ --portable",
"prestart_bak": "yarn build",
"flow": "flow check",
"flow-typed": "rimraf flow-typed/npm && flow-typed install --overwrite || true",
diff --git a/resources/tagspacesp b/resources/tagspacesp
new file mode 100644
index 000000000..2ae810045
--- /dev/null
+++ b/resources/tagspacesp
@@ -0,0 +1,2 @@
+#!/bin/bash
+./tagspaces --portable &
\ No newline at end of file
diff --git a/resources/tagspacesp.cmd b/resources/tagspacesp.cmd
new file mode 100644
index 000000000..0b1729527
--- /dev/null
+++ b/resources/tagspacesp.cmd
@@ -0,0 +1 @@
+start /B tagspaces.exe --portable
\ No newline at end of file