portable mode

This commit is contained in:
Joao Moreno
2018-06-13 17:13:55 +02:00
parent d631cb8076
commit bd799550fe
4 changed files with 106 additions and 12 deletions

View File

@@ -3,6 +3,37 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Error.stackTraceLimit = 100; // increase number of stack frames (from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)
const fs = require('fs');
const path = require('path');
const product = require('../product.json');
const appRoot = path.dirname(__dirname);
function getApplicationPath() {
if (process.env['VSCODE_DEV']) {
return appRoot;
} else if (process.platform === 'darwin') {
return path.dirname(path.dirname(path.dirname(appRoot)));
} else {
return path.dirname(path.dirname(appRoot));
}
}
function getPortableDataPath() {
return path.join(path.dirname(getApplicationPath()), product.portable);
}
if (product.portable) {
const portablePath = getPortableDataPath();
try { fs.mkdirSync(portablePath); } catch (err) { if (err.code !== 'EEXIST') { throw err; } }
const tmpdir = path.join(portablePath, 'tmp');
try { fs.mkdirSync(tmpdir); } catch (err) { if (err.code !== 'EEXIST') { throw err; } }
process.env[process.platform === 'win32' ? 'TEMP' : 'TMPDIR'] = tmpdir;
}
//#region Add support for using node_modules.asar
(function () {
const path = require('path');