add language tag automatically for contributions

related to #83
This commit is contained in:
Joao Moreno 2016-04-15 12:42:47 +02:00
parent 8fe3e91f31
commit 4b8c129e54
2 changed files with 30 additions and 9 deletions

View file

@ -134,19 +134,24 @@ export class TagsProcessor extends BaseProcessor {
return promise.then<any>(keywords => {
const contributes = this.manifest.contributes;
const themes = contributes && contributes['themes'];
if (themes && themes.length > 0) {
keywords = [...keywords, 'theme'];
}
const activationEvents = this.manifest.activationEvents || [];
const languages = activationEvents
const themes = contributes && contributes['themes'] && contributes['themes'].length > 0 ? ['theme'] : [];
const languageContributions = ((contributes && contributes['languages']) || [])
.map(l => l.id);
const languageActivations = activationEvents
.map(e => /^onLanguage:(.*)$/.exec(e))
.filter(r => !!r)
.map(r => r[1]);
keywords = [...keywords, ...languages];
keywords = [
...keywords,
...themes,
...languageContributions,
...languageActivations
];
this.vsix.tags = _.unique(keywords).join(',');
});

View file

@ -460,7 +460,7 @@ describe('toVsixManifest', () => {
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags[0], ''));
});
it('should automatically add language tag', () => {
it('should automatically add language tag with activationEvent', () => {
const manifest = {
name: 'test',
publisher: 'mocha',
@ -474,6 +474,22 @@ describe('toVsixManifest', () => {
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags[0], 'go'));
});
it('should automatically add language tag with language contribution', () => {
const manifest = {
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null),
contributes: {
languages: [{ id: 'go' }]
}
};
return _toVsixManifest(manifest, [])
.then(parseXml)
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags[0], 'go'));
});
it('should remove duplicate tags', () => {
const manifest = {
name: 'test',