Skip to content

Commit

Permalink
[vscode] support env:NAME variable substitution
Browse files Browse the repository at this point in the history
VS Code doc: https://code.visualstudio.com/docs/editor/variables-reference#_environment-variables

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Jul 29, 2019
1 parent f5161db commit 307dc1b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v0.10.0

- [vscode] added env variable substitution support [5811](https://github.com/theia-ide/theia/pull/5811)

## v0.9.0
- [core] added `theia-widget-noInfo` css class to be used by widgets when displaying no information messages [#5717](https://github.com/theia-ide/theia/pull/5717)
- [core] added additional options to the tree search input [#5566](https://github.com/theia-ide/theia/pull/5566)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/********************************************************************************
* Copyright (C) 2019 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject } from 'inversify';
import { VariableContribution, VariableRegistry } from './variable';
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';

@injectable()
export class EnvVariableContribution implements VariableContribution {

@inject(EnvVariablesServer)
protected readonly env: EnvVariablesServer;

async registerVariables(variables: VariableRegistry): Promise<void> {
for (const variable of await this.env.getVariables()) {
variables.registerVariable({
name: 'env:' + variable.name,
resolve: () => variable.value
});
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { VariableRegistry, VariableContribution } from './variable';
import { VariableQuickOpenService } from './variable-quick-open-service';
import { VariableResolverFrontendContribution } from './variable-resolver-frontend-contribution';
import { VariableResolverService } from './variable-resolver-service';
import { EnvVariableContribution } from './env-variable-contribution';

export default new ContainerModule(bind => {
bind(VariableRegistry).toSelf().inSingletonScope();
Expand All @@ -33,4 +34,7 @@ export default new ContainerModule(bind => {
}

bind(VariableQuickOpenService).toSelf().inSingletonScope();

bind(EnvVariableContribution).toSelf().inSingletonScope();
bind(VariableContribution).toService(EnvVariableContribution);
});

0 comments on commit 307dc1b

Please sign in to comment.