move debugPluginHost parsing out of env
tests included!
This commit is contained in:
parent
9c4711cb60
commit
d977e9cfcd
|
@ -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)) {
|
||||
|
|
|
@ -42,7 +42,9 @@ const options: minimist.Opts = {
|
|||
'extensionTestsPath',
|
||||
'timestamp',
|
||||
'install-extension',
|
||||
'uninstall-extension'
|
||||
'uninstall-extension',
|
||||
'debugBrkPluginHost',
|
||||
'debugPluginHost'
|
||||
],
|
||||
boolean: [
|
||||
'help',
|
||||
|
|
|
@ -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 };
|
||||
}
|
|
@ -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 });
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue