Skip to content

Commit

Permalink
Now using child_process.fork() to run node-based debug adapters; also…
Browse files Browse the repository at this point in the history
… handles Electron

Signed-off-by: Eyal Barlev <eyal.barlev@sap.com>
  • Loading branch information
perspectivus1 committed Jul 18, 2019
1 parent 32806e1 commit 6e6bba1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 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 @@ -233,10 +233,10 @@ export abstract class AbstractVSCodeDebugAdapterContribution implements DebugAda
const runtimeArgs = info && info.runtimeArgs || contribution.runtimeArgs || [];
if (runtime === 'node') {
const modulePath = program;
const args = [...runtimeArgs, ...programArgs];
return {
modulePath,
args
modulePath: modulePath,
execArgv: runtimeArgs,
args: programArgs
};
} else {
const command = runtime ? runtime : program;
Expand Down

0 comments on commit 6e6bba1

Please sign in to comment.