Update Notifier Tweaks
This commit is contained in:
		
							parent
							
								
									238dd4a996
								
							
						
					
					
						commit
						a26f829399
					
				
					 3 changed files with 13 additions and 5 deletions
				
			
		|  | @ -3,10 +3,11 @@ | |||
| import { commands, ExtensionContext } from 'vscode'; | ||||
| import { formatXml, linearizeXml } from './features/xmlFormatting'; | ||||
| import { evaluateXPath } from './features/xmlXPathEngine'; | ||||
| import { checkForUpdates } from './utils/UpdateNotifier'; | ||||
| 
 | ||||
| export function activate(ctx: ExtensionContext) { | ||||
| 	// check for update
 | ||||
| 	//...
 | ||||
| 	checkForUpdates(); | ||||
| 	 | ||||
| 	// register palette commands
 | ||||
| 	ctx.subscriptions.push(commands.registerTextEditorCommand('xmltools.formatXml', formatXml)); | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ import { extensions, Extension } from 'vscode'; | |||
| export class ExtensionManifestReader { | ||||
| 	constructor(extensionId: string) { | ||||
| 		this._extension = extensions.getExtension(extensionId); | ||||
| 		this.refresh(); | ||||
| 	} | ||||
| 	 | ||||
| 	private _extension: Extension<any> | ||||
|  | @ -27,7 +28,7 @@ export class ExtensionManifestReader { | |||
| 	} | ||||
| 	 | ||||
| 	refresh(): void { | ||||
| 		let manifest: any = this._extension.packageJSON; | ||||
| 		let manifest = this._extension.packageJSON; | ||||
| 		 | ||||
| 		for (let property in manifest) | ||||
| 		{ | ||||
|  | @ -35,5 +36,7 @@ export class ExtensionManifestReader { | |||
| 				this[property] = manifest[property]; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		this.displayName = manifest.displayName; | ||||
| 	} | ||||
| } | ||||
|  | @ -6,9 +6,9 @@ import { ExtensionManifestReader } from './ManifestUtils'; | |||
| let req = require('request'); | ||||
| let semver = require('semver'); | ||||
| 
 | ||||
| export function checkForUpdates() { | ||||
| export function checkForUpdates() {	 | ||||
| 	let manifestReader: ExtensionManifestReader = new ExtensionManifestReader('DotJoshJohnson.xml'); | ||||
| 	let currentVersion = manifestReader.version; | ||||
| 	let currentVersion = '0.0.0';//manifestReader.version;
 | ||||
| 	 | ||||
| 	// use the GitHub api to determine the latest released version
 | ||||
| 	let url = 'https://api.github.com/repos/DotJoshJohnson/vscode-xml/releases/latest'; | ||||
|  | @ -24,7 +24,7 @@ export function checkForUpdates() { | |||
| 	req(options, (error, response, body) => { | ||||
| 		if (!error && response.statusCode == 200) { | ||||
| 			let release = JSON.parse(body); | ||||
| 			let latestVersion = release.name.substring(1); // the telease/tag is prefixed with a "v"
 | ||||
| 			let latestVersion = release.name.substring(1); // the release/tag is prefixed with a "v"
 | ||||
| 			 | ||||
| 			if (!release.draft && semver.gt(latestVersion, currentVersion)) { | ||||
| 				let updateNowLabel = 'Update Now'; | ||||
|  | @ -35,5 +35,9 @@ export function checkForUpdates() { | |||
| 				}); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		else { | ||||
| 			console.log('XML Tools: Failed to get latest release information from GitHub.'); | ||||
| 		} | ||||
| 	}); | ||||
| } | ||||
		Loading…
	
	Add table
		
		Reference in a new issue