diff options
author | Benjamin Pasero <benjamin.pasero@gmail.com> | 2018-09-07 13:23:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-07 13:23:09 +0300 |
commit | a4bf919e598df2b908716e9470123007b6477c81 (patch) | |
tree | ead9c71308ad7cb042d2cd7fee9e6f6763c87a09 /src/cli.js | |
parent | 27bb0131b07f42d70b5a039befeecdea4ac1fa8b (diff) |
Cleanup bootstrap files (#58171)
* bootstrap - first cut
* bootstrap => bootstrap-fork, bootstrap-shared => bootstrap
* bootstrap - extract uriFromPath()
* bootstrap - extract readfile/writefile
* bootstrap - share more code when loading renderers
* boostrap-electron-browser => bootstrap-window
* bootstrap - cleanup main.js
* bootstrap - handle index.js
* bootstrap :lipstick:
Diffstat (limited to 'src/cli.js')
-rw-r--r-- | src/cli.js | 74 |
1 files changed, 7 insertions, 67 deletions
diff --git a/src/cli.js b/src/cli.js index 41d46871f92..d464953c4b7 100644 --- a/src/cli.js +++ b/src/cli.js @@ -3,73 +3,13 @@ * 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 bootstrap = require('./bootstrap'); -const fs = require('fs'); -const path = require('path'); -const product = require('../product.json'); -const appRoot = path.dirname(__dirname); +// Enable portable support +bootstrap.configurePortable(); -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)); - } -} +// Enable ASAR support +bootstrap.enableASARSupport(); -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); - -if (isPortable) { - process.env['VSCODE_PORTABLE'] = portableDataPath; -} else { - delete process.env['VSCODE_PORTABLE']; -} - -if (isTempPortable) { - process.env[process.platform === 'win32' ? 'TEMP' : 'TMPDIR'] = portableTempPath; -} - -//#region Add support for using node_modules.asar -(function () { - const path = require('path'); - const Module = require('module'); - const NODE_MODULES_PATH = path.join(__dirname, '../node_modules'); - const NODE_MODULES_ASAR_PATH = NODE_MODULES_PATH + '.asar'; - - const originalResolveLookupPaths = Module._resolveLookupPaths; - Module._resolveLookupPaths = function (request, parent, newReturn) { - const result = originalResolveLookupPaths(request, parent, newReturn); - - const paths = newReturn ? result : result[1]; - for (let i = 0, len = paths.length; i < len; i++) { - if (paths[i] === NODE_MODULES_PATH) { - paths.splice(i, 0, NODE_MODULES_ASAR_PATH); - break; - } - } - - return result; - }; -})(); -//#endregion - -require('./bootstrap-amd').bootstrap('vs/code/node/cli');
\ No newline at end of file +// Load CLI through AMD loader +require('./bootstrap-amd').load('vs/code/node/cli');
\ No newline at end of file |