Skip to content

Commit

Permalink
exclude some env variables (#2988)
Browse files Browse the repository at this point in the history
  • Loading branch information
elahehrashedi authored Feb 1, 2023
1 parent 82e5e59 commit dc0bd4b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Improvements:

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

## 1.13.45
Bug Fixes:
Expand Down
3 changes: 3 additions & 0 deletions src/environmentVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const envProperty = Symbol('envProperty');
// alias of NodeJS.ProcessEnv, Record<string, string | undefined> === Dict<string>
export type Environment = Record<string, string | undefined>;
export type EnvironmentWithNull = Record<string, string | undefined | null>;
const filter: RegExp = /\$\{.+?\}/;

export interface EnvironmentOptions {
preserveNull?: boolean;
Expand Down Expand Up @@ -76,6 +77,8 @@ class EnvironmentPrivate {
if (!this.options.preserveNull) {
deleteKey = true;
}
} else if (key.match(filter)) {
deleteKey = true;
} else if (typeof value !== 'string') {
value = '' + value;
}
Expand Down
5 changes: 3 additions & 2 deletions src/kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,9 @@ export async function getShellScriptEnvironment(kit: Kit, opts?: expand.Expansio
return;
}

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

0 comments on commit dc0bd4b

Please sign in to comment.