From 8ab1980777d3d673b5c64cc7e95dbb306412b71e Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Tue, 25 Feb 2020 13:43:25 +0100 Subject: [PATCH] Added an example. You can create a `.theia-example` folder in your workspace, create a `tasks.json`, and put your tasks there. Signed-off-by: Akos Kitta --- examples/api-samples/package.json | 3 ++- .../src/node/example-env-variables-module.ts | 23 ++++++++++++++++ .../src/node/example-env-variables-server.ts | 27 +++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 examples/api-samples/src/node/example-env-variables-module.ts create mode 100644 examples/api-samples/src/node/example-env-variables-server.ts diff --git a/examples/api-samples/package.json b/examples/api-samples/package.json index 014d7bbf486e4..46a63e718d58b 100644 --- a/examples/api-samples/package.json +++ b/examples/api-samples/package.json @@ -8,7 +8,8 @@ }, "theiaExtensions": [ { - "frontend": "lib/browser/api-samples-frontend-module" + "frontend": "lib/browser/api-samples-frontend-module", + "backend": "lib/node/example-env-variables-module" } ], "keywords": [ diff --git a/examples/api-samples/src/node/example-env-variables-module.ts b/examples/api-samples/src/node/example-env-variables-module.ts new file mode 100644 index 0000000000000..2df86a68d1850 --- /dev/null +++ b/examples/api-samples/src/node/example-env-variables-module.ts @@ -0,0 +1,23 @@ +/******************************************************************************** + * Copyright (C) 2020 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 { ContainerModule } from 'inversify'; +import { EnvVariablesServer } from '@theia/core/lib/common/env-variables'; +import { ExampleEnvVariableServer } from './example-env-variables-server'; + +export default new ContainerModule((bind, unbind, isBound, rebind) => { + rebind(EnvVariablesServer).to(ExampleEnvVariableServer).inSingletonScope(); +}); diff --git a/examples/api-samples/src/node/example-env-variables-server.ts b/examples/api-samples/src/node/example-env-variables-server.ts new file mode 100644 index 0000000000000..45cd9109dbc66 --- /dev/null +++ b/examples/api-samples/src/node/example-env-variables-server.ts @@ -0,0 +1,27 @@ +/******************************************************************************** + * Copyright (C) 2020 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 } from 'inversify'; +import { EnvVariablesServerImpl } from '@theia/core/lib/node/env-variables'; + +@injectable() +export class ExampleEnvVariableServer extends EnvVariablesServerImpl { + + get configDirName(): string { + return '.theia-example'; + } + +}