Skip to content

Commit

Permalink
Ensure node-based debug adapters spawn same node as Theia
Browse files Browse the repository at this point in the history
Signed-off-by: Eyal Barlev <eyal.barlev@sap.com>
  • Loading branch information
perspectivus1 authored and akosyakov committed Jul 25, 2019
1 parent 22ef59c commit 7a419b7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/debug/src/common/debug-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface DebugAdapterSpawnExecutable {
*/
export interface DebugAdapterForkExecutable {
modulePath: string;
execArgv?: string[];
args?: string[];
}

Expand Down
8 changes: 6 additions & 2 deletions packages/debug/src/node/debug-adapter-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ import {
CommunicationProvider,
DebugAdapterSession,
DebugAdapterSessionFactory,
DebugAdapterFactory
DebugAdapterFactory,
DebugAdapterForkExecutable
} from '../common/debug-model';
import { DebugAdapterSessionImpl } from './debug-adapter-session';
import { environment } from '@theia/application-package';

/**
* [DebugAdapterFactory](#DebugAdapterFactory) implementation based on
Expand Down Expand Up @@ -67,10 +69,12 @@ export class LaunchBasedDebugAdapterFactory implements DebugAdapterFactory {
!!forkOptions && !!forkOptions.modulePath;

const processOptions: RawProcessOptions | RawForkOptions = { ...executable };
const options = { stdio: ['pipe', 'pipe', 2] };
const options: { stdio: (string | number)[], env?: object, execArgv?: string[] } = { stdio: ['pipe', 'pipe', 2] };

if (isForkOptions(processOptions)) {
options.stdio.push('ipc');
options.env = environment.electron.runAsNodeEnv();
options.execArgv = (executable as DebugAdapterForkExecutable).execArgv;
}

processOptions.options = options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,22 @@ export abstract class AbstractVSCodeDebugAdapterContribution implements DebugAda
if (runtime && runtime.indexOf('./') === 0) {
runtime = path.join(this.extensionPath, runtime);
}

const runtimeArgs = info && info.runtimeArgs || contribution.runtimeArgs || [];
const command = runtime ? runtime : program;
const args = runtime ? [...runtimeArgs, program, ...programArgs] : programArgs;
return {
command,
args
};
if (runtime === 'node') {
const modulePath = program;
return {
modulePath: modulePath,
execArgv: runtimeArgs,
args: programArgs
};
} else {
const command = runtime ? runtime : program;
const args = runtime ? [...runtimeArgs, program, ...programArgs] : programArgs;
return {
command,
args
};
}
}
}

0 comments on commit 7a419b7

Please sign in to comment.