add language tag automatically

related to #83
This commit is contained in:
Joao Moreno 2016-04-15 12:37:10 +02:00
parent f26f398300
commit 8fe3e91f31
2 changed files with 25 additions and 3 deletions

View file

@ -140,6 +140,14 @@ export class TagsProcessor extends BaseProcessor {
keywords = [...keywords, 'theme'];
}
const activationEvents = this.manifest.activationEvents || [];
const languages = activationEvents
.map(e => /^onLanguage:(.*)$/.exec(e))
.filter(r => !!r)
.map(r => r[1]);
keywords = [...keywords, ...languages];
this.vsix.tags = _.unique(keywords).join(',');
});
}

View file

@ -441,7 +441,7 @@ describe('toVsixManifest', () => {
return _toVsixManifest(manifest, [])
.then(parseXml)
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags, ['theme']));
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags[0], 'theme'));
});
it('should not automatically add theme tag when themes are empty', () => {
@ -457,7 +457,21 @@ describe('toVsixManifest', () => {
return _toVsixManifest(manifest, [])
.then(parseXml)
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags, ['']));
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags[0], ''));
});
it('should automatically add language tag', () => {
const manifest = {
name: 'test',
publisher: 'mocha',
version: '0.0.1',
engines: Object.create(null),
activationEvents: ['onLanguage:go']
};
return _toVsixManifest(manifest, [])
.then(parseXml)
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags[0], 'go'));
});
it('should remove duplicate tags', () => {
@ -471,7 +485,7 @@ describe('toVsixManifest', () => {
return _toVsixManifest(manifest, [])
.then(parseXml)
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags, ['theme']));
.then(result => assert.deepEqual(result.PackageManifest.Metadata[0].Tags[0], 'theme'));
});
});