Skip to content

Commit 5c98d6c

Browse files
committed
Merge branch 'envVariables'
2 parents a023301 + 91e5e3a commit 5c98d6c

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@
120120
"WaitOnNormalExit",
121121
"RedirectOutput"
122122
]
123-
}
123+
},
124+
"env": {
125+
"type": "object",
126+
"description": "Environment variables defined as a key value pair. Property ends up being the Environment Variable and the value of the property ends up being the value of the Env Variable.",
127+
"default": null
128+
}
124129
}
125130
},
126131
"attach": {

src/client/common/open.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export function open(opts: any): Promise<childProcess.ChildProcess> {
1919
if (opts.cwd) {
2020
cpOpts.cwd = opts.cwd;
2121
}
22+
if (opts.env) {
23+
cpOpts.env = opts.env;
24+
}
2225

2326
if (Array.isArray(opts.app)) {
2427
appArgs = opts.app.slice(1);

src/client/debugger/Common/Contracts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArgum
2727
externalConsole?: boolean;
2828
cwd?: string;
2929
debugOptions?: string[];
30+
env?: Object;
3031
}
3132
//
3233
// export interface LaunchDjangoRequestArguments extends LaunchRequestArguments {

src/client/debugger/DebugClients/LocalDebugClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class LocalDebugClient extends DebugClient {
5454
if (typeof this.args.pythonPath === "string" && this.args.pythonPath.trim().length > 0) {
5555
pythonPath = this.args.pythonPath;
5656
}
57-
57+
var environmentVariables = this.args.env ? this.args.env : {};
5858
//GUID is hardcoded for now, will have to be fixed
5959
var currentFileName = module.filename;
6060
var ptVSToolsFilePath = path.join(path.dirname(currentFileName), "..", "..", "..", "..", "pythonFiles", "PythonTools", "visualstudio_py_launcher.py");
@@ -63,7 +63,7 @@ export class LocalDebugClient extends DebugClient {
6363
var args = [ptVSToolsFilePath, fileDir, dbgServer.port.toString(), "34806ad9-833a-4524-8cd6-18ca4aa74f14"].concat(launcherArgs);
6464
console.log(pythonPath + " " + args.join(" "));
6565
if (this.args.externalConsole === true) {
66-
open({ wait: false, app: [pythonPath].concat(args), cwd:processCwd }).then(proc=> {
66+
open({ wait: false, app: [pythonPath].concat(args), cwd: processCwd, env: environmentVariables }).then(proc=> {
6767
this.pyProc = proc;
6868
resolve();
6969
}, error=> {
@@ -80,7 +80,7 @@ export class LocalDebugClient extends DebugClient {
8080
return;
8181
}
8282

83-
this.pyProc = child_process.spawn(pythonPath, args, { cwd: processCwd });
83+
this.pyProc = child_process.spawn(pythonPath, args, { cwd: processCwd, env: environmentVariables });
8484
this.pyProc.on("error", error=> {
8585
if (!this.debugServer && this.debugServer.IsRunning) {
8686
return;

0 commit comments

Comments
 (0)