Merge from master

This commit is contained in:
Raj Musuku
2019-02-21 17:56:04 -08:00
parent 5a146e34fa
commit 666ae11639
11482 changed files with 119352 additions and 255574 deletions

View File

@@ -3,12 +3,13 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as semver from 'semver';
import { adoptToGalleryExtensionId, LOCAL_EXTENSION_ID_REGEX } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { IExtensionManifest } from 'vs/platform/extensionManagement/common/extensionManagement';
import { buffer } from 'vs/platform/node/zip';
import { localize } from 'vs/nls';
export function getIdAndVersionFromLocalExtensionId(localExtensionId: string): { id: string, version: string } {
export function getIdAndVersionFromLocalExtensionId(localExtensionId: string): { id: string, version: string | null } {
const matches = LOCAL_EXTENSION_ID_REGEX.exec(localExtensionId);
if (matches && matches[1] && matches[2]) {
const version = semver.valid(matches[2]);
@@ -20,4 +21,15 @@ export function getIdAndVersionFromLocalExtensionId(localExtensionId: string): {
id: adoptToGalleryExtensionId(localExtensionId),
version: null
};
}
export function getManifest(vsix: string): Promise<IExtensionManifest> {
return buffer(vsix, 'extension/package.json')
.then(buffer => {
try {
return JSON.parse(buffer.toString('utf8'));
} catch (err) {
throw new Error(localize('invalidManifest', "VSIX invalid: package.json is not a JSON file."));
}
});
}