|
5 | 5 | *--------------------------------------------------------*/
|
6 | 6 |
|
7 | 7 | import vscode = require('vscode');
|
| 8 | +import semver = require('semver'); |
8 | 9 | import { extensionId } from './const';
|
9 | 10 |
|
10 | 11 | /** getGoConfig is declared as an exported const rather than a function, so it can be stubbbed in testing. */
|
@@ -34,16 +35,21 @@ export class ExtensionInfo {
|
34 | 35 | readonly version?: string;
|
35 | 36 | /** The application name of the editor, like 'VS Code' */
|
36 | 37 | readonly appName: string;
|
37 |
| - /** True if the extension runs in preview mode (e.g. Nightly) */ |
| 38 | + /** True if the extension runs in preview mode (e.g. Nightly, prerelease) */ |
38 | 39 | readonly isPreview: boolean;
|
39 | 40 | /** True if the extension runs in well-kwnon cloud IDEs */
|
40 | 41 | readonly isInCloudIDE: boolean;
|
41 | 42 |
|
42 | 43 | constructor() {
|
43 | 44 | const packageJSON = vscode.extensions.getExtension(extensionId)?.packageJSON;
|
44 |
| - this.version = packageJSON?.version; |
| 45 | + const version = semver.parse(packageJSON?.version); |
| 46 | + this.version = version?.format(); |
45 | 47 | this.appName = vscode.env.appName;
|
46 |
| - this.isPreview = !!packageJSON?.preview; |
| 48 | + |
| 49 | + // golang.go-nightly: packageJSON.preview is true. |
| 50 | + // golang.go prerelease: minor version is an odd number. |
| 51 | + this.isPreview = |
| 52 | + !!packageJSON?.preview || !!(extensionId === 'golang.go' && version && version.minor % 2 === 1); |
47 | 53 | this.isInCloudIDE =
|
48 | 54 | process.env.CLOUD_SHELL === 'true' ||
|
49 | 55 | process.env.MONOSPACE_ENV === 'true' ||
|
|
0 commit comments