Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure node-based debug adapters spawn same node exec as Theia #5508

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not it redundant? executable is already spread into processOptions here: https://github.com/theia-ide/theia/pull/5508/files#diff-0edd7bfb7a3a6822ad4c2bf344b5f8f1R71

}

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
};
}
}
}