diff --git a/src/vs/code/electron-main/env.ts b/src/vs/code/electron-main/env.ts index e729e48bc5b..91e7ce50d84 100644 --- a/src/vs/code/electron-main/env.ts +++ b/src/vs/code/electron-main/env.ts @@ -142,11 +142,6 @@ export class EnvService implements IEnvService { } const argv = parseArgs(args); - - const debugBrkExtensionHostPort = getNumericValue(argv.debugBrkPluginHost, 5870); - const debugExtensionHostPort = getNumericValue(argv.debugPluginHost, 5870, this.isBuilt ? void 0 : 5870); - const debugPluginHost = debugBrkExtensionHostPort ? String(debugBrkExtensionHostPort) : debugExtensionHostPort ? String(debugExtensionHostPort): void 0; - const debugBrkPluginHost = debugBrkExtensionHostPort ? String(true) : void 0; const paths = parsePathArguments(this._currentWorkingDirectory, argv._, argv.goto); const timestamp = parseInt(argv.timestamp); const debugBrkFileWatcherPort = getNumericValue(argv.debugBrkFileWatcherPort, void 0); @@ -157,8 +152,8 @@ export class EnvService implements IEnvService { timestamp: types.isNumber(timestamp) ? String(timestamp) : '0', performance: argv.performance, verbose: argv.verbose, - debugPluginHost, - debugBrkPluginHost, + debugPluginHost: argv.debugPluginHost, + debugBrkPluginHost: argv.debugBrkPluginHost, logExtensionHostCommunication: argv.logExtensionHostCommunication, debugBrkFileWatcherPort: debugBrkFileWatcherPort ? String(debugBrkFileWatcherPort) : void 0, 'new-window': argv['new-window'], @@ -293,14 +288,6 @@ function normalizePath(p?: string): string { return p ? path.normalize(p) : p; } -export function getPlatformIdentifier(): string { - if (process.platform === 'linux') { - return `linux-${process.arch}`; - } - - return process.platform; -} - export interface IParsedPath { path: string; line?: number; @@ -332,7 +319,7 @@ export function parseLineAndColumnAware(rawPath: string): IParsedPath { }; } -export function toLineAndColumnPath(parsedPath: IParsedPath): string { +function toLineAndColumnPath(parsedPath: IParsedPath): string { let segments = [parsedPath.path]; if (types.isNumber(parsedPath.line)) { diff --git a/src/vs/code/node/argv.ts b/src/vs/code/node/argv.ts index 20e756c1380..a8f2274bbf0 100644 --- a/src/vs/code/node/argv.ts +++ b/src/vs/code/node/argv.ts @@ -42,7 +42,9 @@ const options: minimist.Opts = { 'extensionTestsPath', 'timestamp', 'install-extension', - 'uninstall-extension' + 'uninstall-extension', + 'debugBrkPluginHost', + 'debugPluginHost' ], boolean: [ 'help', diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index 21f61ced9b3..062d00123b5 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -78,12 +78,17 @@ export class EnvironmentService implements IEnvironmentService { this._extensionDevelopmentPath = args.extensionDevelopmentPath; - if (args.debugPluginHost) { - this._debugExtensionHostPort = Number(args.debugPluginHost); - } - - this._debugBrkExtensionHost = Boolean(args.debugBrkPluginHost); + const { port, brk } = parseExtensionHostPort(args, this.isBuilt); + this._debugExtensionHostPort = port; + this._debugBrkExtensionHost = brk; this._debugBrkFileWatcherPort = (typeof args.debugBrkFileWatcherPort === 'string') ? Number(args.debugBrkFileWatcherPort) : void 0; } +} + +export function parseExtensionHostPort(args: ParsedArgs, isBuild: boolean): { port: number; brk: boolean; } { + const portStr = args.debugBrkPluginHost || args.debugPluginHost; + const port = Number(portStr) || (!isBuild ? 5870 : null); + const brk = port ? Boolean(!!args.debugBrkPluginHost) : false; + return { port, brk }; } \ No newline at end of file diff --git a/src/vs/platform/environment/test/node/environmentService.test.ts b/src/vs/platform/environment/test/node/environmentService.test.ts new file mode 100644 index 00000000000..8e8db20a8ec --- /dev/null +++ b/src/vs/platform/environment/test/node/environmentService.test.ts @@ -0,0 +1,34 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import * as assert from 'assert'; +import { parseArgs } from 'vs/code/node/argv'; +import { parseExtensionHostPort } from 'vs/platform/environment/node/environmentService'; + +suite('EnvironmentService', () => { + + test('parseExtensionHostPort when built', () => { + const parse = a => parseExtensionHostPort(parseArgs(a), true); + + assert.deepEqual(parse([]), { port: null, brk: false }); + assert.deepEqual(parse(['--debugPluginHost']), { port: null, brk: false }); + assert.deepEqual(parse(['--debugPluginHost=1234']), { port: 1234, brk: false }); + assert.deepEqual(parse(['--debugBrkPluginHost']), { port: null, brk: false }); + assert.deepEqual(parse(['--debugBrkPluginHost=5678']), { port: 5678, brk: true }); + assert.deepEqual(parse(['--debugPluginHost=1234', '--debugBrkPluginHost=5678']), { port: 5678, brk: true }); + }); + + test('parseExtensionHostPort when unbuilt', () => { + const parse = a => parseExtensionHostPort(parseArgs(a), false); + + assert.deepEqual(parse([]), { port: 5870, brk: false }); + assert.deepEqual(parse(['--debugPluginHost']), { port: 5870, brk: false }); + assert.deepEqual(parse(['--debugPluginHost=1234']), { port: 1234, brk: false }); + assert.deepEqual(parse(['--debugBrkPluginHost']), { port: 5870, brk: false }); + assert.deepEqual(parse(['--debugBrkPluginHost=5678']), { port: 5678, brk: true }); + assert.deepEqual(parse(['--debugPluginHost=1234', '--debugBrkPluginHost=5678']), { port: 5678, brk: true }); + }); +}); \ No newline at end of file