Skip to content

Commit dc0bd4b

Browse files
author
Elaheh Rashedi
authored
exclude some env variables (#2988)
1 parent 82e5e59 commit dc0bd4b

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Improvements:
66

77
Bug Fixes:
88
- Check if "CMakeLists.txt" exists after renaming. [#2986](https://github.com/microsoft/vscode-cmake-tools/issues/2986)
9+
- CMake kits fails when parsing exported functions after running environmentSetupScript. [#2676](https://github.com/microsoft/vscode-cmake-tools/issues/2686)
910

1011
## 1.13.45
1112
Bug Fixes:

src/environmentVariables.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const envProperty = Symbol('envProperty');
77
// alias of NodeJS.ProcessEnv, Record<string, string | undefined> === Dict<string>
88
export type Environment = Record<string, string | undefined>;
99
export type EnvironmentWithNull = Record<string, string | undefined | null>;
10+
const filter: RegExp = /\$\{.+?\}/;
1011

1112
export interface EnvironmentOptions {
1213
preserveNull?: boolean;
@@ -76,6 +77,8 @@ class EnvironmentPrivate {
7677
if (!this.options.preserveNull) {
7778
deleteKey = true;
7879
}
80+
} else if (key.match(filter)) {
81+
deleteKey = true;
7982
} else if (typeof value !== 'string') {
8083
value = '' + value;
8184
}

src/kit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,9 @@ export async function getShellScriptEnvironment(kit: Kit, opts?: expand.Expansio
666666
return;
667667
}
668668

669-
// split and trim env vars
670-
const vars = env.split('\n').map(l => l.trim()).filter(l => l.length !== 0).reduce<Environment>((acc, line) => {
669+
// split and trim env vars, and exclude ${variables}
670+
const filter: RegExp = /\$\{.+?\}/;
671+
const vars = env.split('\n').map(line => line.trim()).filter(line => (line.length !== 0 && !line.match(filter))).reduce<Environment>((acc, line) => {
671672
const match = /(\w+)=?(.*)/.exec(line);
672673
if (match) {
673674
acc[match[1]] = match[2];

0 commit comments

Comments
 (0)