Skip to content

Commit 9d901f3

Browse files
committed
同步全局环境变量到插件进程
1 parent 896e200 commit 9d901f3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/SettingManager.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ export class SettingManager {
112112
this.refreshC51Status();
113113
}
114114

115+
if (e.affectsConfiguration('EIDE.Builder.EnvironmentVariables')) {
116+
this.syncGlobalEnvVariablesToNodeEnv();
117+
}
118+
115119
} catch (error) {
116120
GlobalEvent.emit('globalLog', ExceptionToMessage(error, 'Hidden'));
117121
}
@@ -252,6 +256,13 @@ export class SettingManager {
252256

253257
//--------------------- Global Option ------------------------
254258

259+
syncGlobalEnvVariablesToNodeEnv() {
260+
const envs = this.getGlobalEnvVariables();
261+
for (const key in envs) {
262+
process.env[key] = envs[key];
263+
}
264+
}
265+
255266
getGlobalEnvVariables(): { [key: string]: string } {
256267
const lines = this.getConfiguration().get<string[]>('Builder.EnvironmentVariables') || [];
257268
const result: { [key: string]: string } = {};

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,8 @@ function exportEnvToSysPath(context?: vscode.ExtensionContext) {
865865
// 支持运行时回滚
866866
// https://learn.microsoft.com/zh-cn/dotnet/core/whats-new/dotnet-core-3-0#major-version-runtime-roll-forward
867867
process.env['DOTNET_ROLL_FORWARD'] = 'Major';
868+
869+
SettingManager.GetInstance().syncGlobalEnvVariablesToNodeEnv();
868870
}
869871

870872
async function checkAndInstallRuntime() {

0 commit comments

Comments
 (0)