diff options
author | Joao Moreno <joao.moreno@microsoft.com> | 2018-06-13 18:13:55 +0300 |
---|---|---|
committer | Joao Moreno <joao.moreno@microsoft.com> | 2018-06-13 18:13:55 +0300 |
commit | bd799550fe9057bf9aa2ef1dbd5c52971b23d3ed (patch) | |
tree | c5ebe3992bf115a60ff1b398f16f6e2e77c3881d /src/cli.js | |
parent | d631cb8076aa8557b30af60ac1014befd8f91926 (diff) |
portable mode
Diffstat (limited to 'src/cli.js')
-rw-r--r-- | src/cli.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/cli.js b/src/cli.js index db7b6cce206..49f934d092a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -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'); |