Skip to content

Commit

Permalink
[vscode] fix resolution of env variables
Browse files Browse the repository at this point in the history
- if an env variable does not exist it should resolve to an empty string to emulate the shell
- normalize env variable name to lower case in order to retrieve them from process.env on windows

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Aug 11, 2019
1 parent 3a2e1fd commit 77f809e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/core/src/node/env-variables/env-variables-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { injectable } from 'inversify';
import { EnvVariable, EnvVariablesServer } from '../../common/env-variables';
import { isWindows } from '../../common/os';

@injectable()
export class EnvVariablesServerImpl implements EnvVariablesServer {
Expand All @@ -38,6 +39,9 @@ export class EnvVariablesServerImpl implements EnvVariablesServer {
}

async getValue(key: string): Promise<EnvVariable | undefined> {
if (isWindows) {
key = key.toLowerCase();
}
return this.envs[key];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export class CommonVariableContribution implements VariableContribution {
name: 'env',
resolve: async (_, envVariableName) => {
const envVariable = envVariableName && await this.env.getValue(envVariableName);
return envVariable && envVariable.value;
const envValue = envVariable && envVariable.value;
return envValue || '';
}
});
variables.registerVariable({
Expand Down

0 comments on commit 77f809e

Please sign in to comment.