Skip to content

Commit 907fbd5

Browse files
author
WebFreak001
committed
Process environment extends original one now #98
1 parent 464e230 commit 907fbd5

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/backend/mi2/mi2.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,27 @@ function couldBeOutput(line: string) {
2727
const trace = false;
2828

2929
export class MI2 extends EventEmitter implements IBackend {
30-
constructor(public application: string, public preargs: string[], public extraargs: string[], public procEnv: any) {
30+
constructor(public application: string, public preargs: string[], public extraargs: string[], procEnv: any) {
3131
super();
32+
33+
if (procEnv) {
34+
var env = {};
35+
// Duplicate process.env so we don't override it
36+
for (var key in process.env)
37+
if (process.env.hasOwnProperty(key))
38+
env[key] = process.env[key];
39+
40+
// Overwrite with user specified variables
41+
for (var key in procEnv) {
42+
if (procEnv.hasOwnProperty(key)) {
43+
if (procEnv === null)
44+
delete env[key];
45+
else
46+
env[key] = procEnv[key];
47+
}
48+
}
49+
this.procEnv = env;
50+
}
3251
}
3352

3453
load(cwd: string, target: string, procArgs: string, separateConsole: string): Thenable<any> {
@@ -693,6 +712,7 @@ export class MI2 extends EventEmitter implements IBackend {
693712

694713
printCalls: boolean;
695714
debugOutput: boolean;
715+
public procEnv: any;
696716
protected isSSH: boolean;
697717
protected sshReady: boolean;
698718
protected currentToken: number = 1;

0 commit comments

Comments
 (0)