From e087b31199659c22c58c0ced4641d1b167ca62e7 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Wed, 27 Jun 2018 15:27:32 +0200 Subject: [PATCH] use data folder for win32 and linux portable mode fixes #53108 --- src/cli.js | 16 ++++++++++++++-- src/main.js | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/cli.js b/src/cli.js index 1bb0476f61f..41d46871f92 100644 --- a/src/cli.js +++ b/src/cli.js @@ -20,8 +20,20 @@ function getApplicationPath() { } } -const portableDataName = product.portable || `${product.applicationName}-portable-data`; -const portableDataPath = path.join(path.dirname(getApplicationPath()), portableDataName); +function getPortableDataPath() { + if (process.env['VSCODE_PORTABLE']) { + return process.env['VSCODE_PORTABLE']; + } + + if (process.platform === 'win32' || process.platform === 'linux') { + return path.join(getApplicationPath(), 'data'); + } else { + const portableDataName = product.portable || `${product.applicationName}-portable-data`; + return path.join(path.dirname(getApplicationPath()), portableDataName); + } +} + +const portableDataPath = getPortableDataPath(); const isPortable = fs.existsSync(portableDataPath); const portableTempPath = path.join(portableDataPath, 'tmp'); const isTempPortable = isPortable && fs.existsSync(portableTempPath); diff --git a/src/main.js b/src/main.js index 2fc84ae20fd..624bf52f0c1 100644 --- a/src/main.js +++ b/src/main.js @@ -27,8 +27,20 @@ function getApplicationPath() { } } -const portableDataName = product.portable || `${product.applicationName}-portable-data`; -const portableDataPath = process.env['VSCODE_PORTABLE'] || path.join(path.dirname(getApplicationPath()), portableDataName); +function getPortableDataPath() { + if (process.env['VSCODE_PORTABLE']) { + return process.env['VSCODE_PORTABLE']; + } + + if (process.platform === 'win32' || process.platform === 'linux') { + return path.join(getApplicationPath(), 'data'); + } else { + const portableDataName = product.portable || `${product.applicationName}-portable-data`; + return path.join(path.dirname(getApplicationPath()), portableDataName); + } +} + +const portableDataPath = getPortableDataPath(); const isPortable = fs.existsSync(portableDataPath); const portableTempPath = path.join(portableDataPath, 'tmp'); const isTempPortable = isPortable && fs.existsSync(portableTempPath);