forked from eclipse-theia/theia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to choose through CLI the VS Code API version that is provided …
…by vscode.version call in a VS Code extension $ yarn run start --vscode-api-version=1.40 (and you'll get 1.40 as API version) note: default value is displayed in help as well Change-Id: I371e3b008f8d9a8bbd9e047dada4f75e1137e17a Signed-off-by: Florent Benoit <[email protected]>
- Loading branch information
Showing
6 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/plugin-ext-vscode/src/node/plugin-vscode-cli-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2019 Red Hat, Inc. 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 { Argv, Arguments } from 'yargs'; | ||
import { CliContribution } from '@theia/core/lib/node/cli'; | ||
import { PluginHostEnvironmentVariable } from '@theia/plugin-ext/lib/common'; | ||
import { VSCODE_DEFAULT_API_VERSION } from './plugin-vscode-init'; | ||
/** | ||
* CLI Contribution allowing to override the VS Code API version which is returned by `vscode.version` API call. | ||
*/ | ||
@injectable() | ||
export class PluginVsCodeCliContribution implements CliContribution, PluginHostEnvironmentVariable { | ||
|
||
static VSCODE_API_VERSION = 'vscode-api-version'; | ||
|
||
protected vsCodeApiVersion: string | undefined; | ||
|
||
configure(conf: Argv): void { | ||
conf.option(PluginVsCodeCliContribution.VSCODE_API_VERSION, { | ||
// tslint:disable-next-line:max-line-length | ||
description: `Overrides the version returned by VSCode API 'vscode.version'. Example: --${PluginVsCodeCliContribution.VSCODE_API_VERSION}=<Wanted Version>. Default [${VSCODE_DEFAULT_API_VERSION}]`, | ||
type: 'string', | ||
nargs: 1 | ||
}); | ||
} | ||
|
||
setArguments(args: Arguments): void { | ||
const arg = args[PluginVsCodeCliContribution.VSCODE_API_VERSION]; | ||
if (arg) { | ||
this.vsCodeApiVersion = arg; | ||
} | ||
} | ||
|
||
process(env: NodeJS.ProcessEnv): void { | ||
if (this.vsCodeApiVersion) { | ||
env['VSCODE_API_VERSION'] = this.vsCodeApiVersion; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters