Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/config.ts')
-rw-r--r--editors/code/src/config.ts40
1 files changed, 20 insertions, 20 deletions
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index d2dc740c09..3b1b0768d3 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -8,10 +8,9 @@ import type { Disposable } from "vscode";
export type RunnableEnvCfgItem = {
mask?: string;
- env: Record<string, string>;
+ env: { [key: string]: { toString(): string } | null };
platform?: string | string[];
};
-export type RunnableEnvCfg = Record<string, string> | RunnableEnvCfgItem[];
type ShowStatusBar = "always" | "never" | { documentSelector: vscode.DocumentSelector };
@@ -261,18 +260,13 @@ export class Config {
return this.get<boolean | undefined>("testExplorer");
}
- runnablesExtraEnv(label: string): Record<string, string> | undefined {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const item = this.get<any>("runnables.extraEnv") ?? this.get<any>("runnableEnv");
- if (!item) return undefined;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const fixRecord = (r: Record<string, any>) => {
- for (const key in r) {
- if (typeof r[key] !== "string") {
- r[key] = String(r[key]);
- }
- }
- };
+ runnablesExtraEnv(label: string): Env {
+ const serverEnv = this.serverExtraEnv;
+ let extraEnv =
+ this.get<
+ RunnableEnvCfgItem[] | { [key: string]: { toString(): string } | null } | null
+ >("runnables.extraEnv") ?? {};
+ if (!extraEnv) return serverEnv;
const platform = process.platform;
const checkPlatform = (it: RunnableEnvCfgItem) => {
@@ -283,19 +277,25 @@ export class Config {
return true;
};
- if (item instanceof Array) {
+ if (extraEnv instanceof Array) {
const env = {};
- for (const it of item) {
+ for (const it of extraEnv) {
const masked = !it.mask || new RegExp(it.mask).test(label);
if (masked && checkPlatform(it)) {
Object.assign(env, it.env);
}
}
- fixRecord(env);
- return env;
+ extraEnv = env;
}
- fixRecord(item);
- return item;
+ const runnableExtraEnv = substituteVariablesInEnv(
+ Object.fromEntries(
+ Object.entries(extraEnv).map(([k, v]) => [
+ k,
+ typeof v === "string" ? v : v?.toString(),
+ ]),
+ ),
+ );
+ return { ...runnableExtraEnv, ...serverEnv };
}
get restartServerOnConfigChange() {