From 3d1cb5e20f7a05314f6fd4261076b0a85546cfe4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 19 Mar 2020 09:32:57 +0100 Subject: Simplify extension tag sniffing --- editors/code/src/config.ts | 20 +++++++------------- editors/code/src/main.ts | 4 ++-- 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 28698ab8e..54b905303 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -38,23 +38,17 @@ export class Config { ] .map(opt => `${this.rootSection}.${opt}`); - readonly packageJsonVersion = vscode + readonly packageJsonVersion: string = vscode .extensions .getExtension(this.extensionId)! .packageJSON - .version as string; // n.n.YYYYMMDD[-nightly] + .version; - /** - * Either `nightly` or `YYYY-MM-DD` (i.e. `stable` release) - */ - readonly extensionReleaseTag: string = (() => { - if (this.packageJsonVersion.endsWith(NIGHTLY_TAG)) return NIGHTLY_TAG; - - const realVersionRegexp = /^\d+\.\d+\.(\d{4})(\d{2})(\d{2})/; - const [, yyyy, mm, dd] = this.packageJsonVersion.match(realVersionRegexp)!; - - return `${yyyy}-${mm}-${dd}`; - })(); + readonly releaseTag: string = vscode + .extensions + .getExtension(this.extensionId)! + .packageJSON + .releaseTag; private cfg!: vscode.WorkspaceConfiguration; diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index d907f3e6f..5297614a9 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -111,7 +111,7 @@ async function bootstrap(config: Config, state: PersistentState): Promise { if (config.channel === "stable") { - if (config.extensionReleaseTag === NIGHTLY_TAG) { + if (config.releaseTag === NIGHTLY_TAG) { vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension. To switch to stable, uninstall the extension and re-install it from the marketplace`); } @@ -219,7 +219,7 @@ async function getServer(config: Config, state: PersistentState): Promise artifact.name === binaryName); assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); -- cgit v1.2.3