mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
portable mode
This commit is contained in:
31
src/cli.js
31
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');
|
||||
|
||||
Reference in New Issue
Block a user