33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import * as objects from 'vs/base/common/objects' ;
7- import { isUri } from 'vs/workbench/contrib/debug/common/debugUtils' ;
8- import * as cp from 'child_process' ;
9- import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
106import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
117import { TerminalLauncher } from 'vs/workbench/contrib/debug/node/terminalSupport' ;
12- import { ITerminalLauncher , IDebugHelperService , ILaunchVSCodeArguments } from 'vs/workbench/contrib/debug/common/debug' ;
8+ import { ITerminalLauncher , IDebugHelperService } from 'vs/workbench/contrib/debug/common/debug' ;
139import { Client as TelemetryClient } from 'vs/base/parts/ipc/node/ipc.cp' ;
1410import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc' ;
1511import { getPathFromAmdModule } from 'vs/base/common/amd' ;
@@ -21,90 +17,13 @@ export class NodeDebugHelperService implements IDebugHelperService {
2117 _serviceBrand : any ;
2218
2319 constructor (
24- @IEnvironmentService private readonly environmentService : IEnvironmentService
2520 ) {
2621 }
2722
2823 createTerminalLauncher ( instantiationService : IInstantiationService ) : ITerminalLauncher {
2924 return instantiationService . createInstance ( TerminalLauncher ) ;
3025 }
3126
32- launchVsCode ( vscodeArgs : ILaunchVSCodeArguments ) : Promise < number > {
33-
34- const spawnOpts : cp . SpawnOptions = {
35- detached : false // https://github.com/Microsoft/vscode/issues/57018
36- } ;
37-
38- if ( vscodeArgs . env ) {
39- // merge environment variables into a copy of the process.env
40- const envArgs = objects . mixin ( objects . mixin ( { } , process . env ) , vscodeArgs . env ) ;
41- // and delete some if necessary
42- Object . keys ( envArgs ) . filter ( k => envArgs [ k ] === null ) . forEach ( key => delete envArgs [ key ] ) ;
43- spawnOpts . env = envArgs ;
44- }
45-
46- let spawnArgs = vscodeArgs . args . map ( a => {
47- if ( ( a . prefix === '--file-uri=' || a . prefix === '--folder-uri=' ) && ! isUri ( a . path ) ) {
48- return ( a . path || '' ) ;
49- }
50- return ( a . prefix || '' ) + ( a . path || '' ) ;
51- } ) ;
52-
53- let runtimeExecutable = this . environmentService [ 'execPath' ] ;
54- if ( ! runtimeExecutable ) {
55- return Promise . reject ( new Error ( `VS Code executable unknown` ) ) ;
56- }
57-
58- // if VS Code runs out of sources, add the VS Code workspace path as the first argument so that Electron turns into VS Code
59- const electronIdx = runtimeExecutable . indexOf ( process . platform === 'win32' ? '\\.build\\electron\\' : '/.build/electron/' ) ;
60- if ( electronIdx > 0 ) {
61- // guess the VS Code workspace path from the executable
62- const vscodeWorkspacePath = runtimeExecutable . substr ( 0 , electronIdx ) ;
63-
64- // only add VS Code workspace path if user hasn't already added that path as a (folder) argument
65- const x = spawnArgs . filter ( a => a . indexOf ( vscodeWorkspacePath ) === 0 ) ;
66- if ( x . length === 0 ) {
67- spawnArgs . unshift ( vscodeWorkspacePath ) ;
68- }
69- }
70-
71- // Workaround for bug Microsoft/vscode#45832
72- if ( process . platform === 'win32' && runtimeExecutable . indexOf ( ' ' ) > 0 ) {
73- let foundArgWithSpace = false ;
74-
75- // check whether there is one arg with a space
76- const args : string [ ] = [ ] ;
77- for ( const a of spawnArgs ) {
78- if ( a . indexOf ( ' ' ) > 0 ) {
79- args . push ( `"${ a } "` ) ;
80- foundArgWithSpace = true ;
81- } else {
82- args . push ( a ) ;
83- }
84- }
85-
86- if ( foundArgWithSpace ) {
87- spawnArgs = args ;
88- runtimeExecutable = `"${ runtimeExecutable } "` ;
89- spawnOpts . shell = true ;
90- }
91- }
92-
93- return new Promise ( ( resolve , reject ) => {
94- const process = cp . spawn ( runtimeExecutable , spawnArgs , spawnOpts ) ;
95- process . on ( 'error' , error => {
96- reject ( error ) ;
97- } ) ;
98- process . on ( 'exit' , code => {
99- if ( code === 0 ) {
100- resolve ( process . pid ) ;
101- } else {
102- reject ( new Error ( `VS Code exited with ${ code } ` ) ) ;
103- }
104- } ) ;
105- } ) ;
106- }
107-
10827 createTelemetryService ( configurationService : IConfigurationService , args : string [ ] ) : TelemetryService | undefined {
10928
11029 const client = new TelemetryClient (
0 commit comments