Skip to content

Commit

Permalink
Add support for misspelled license name (#879)
Browse files Browse the repository at this point in the history
* feat: add support for misspelled license name

* test: check for misspelled license files
  • Loading branch information
bandantonio authored Jul 10, 2023
1 parent 11dd270 commit 701a450
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,8 @@ class LicenseProcessor extends BaseProcessor {
const match = /^SEE LICENSE IN (.*)$/.exec(manifest.license || '');

if (!match || !match[1]) {
this.expectedLicenseName = 'LICENSE.md, LICENSE.txt or LICENSE';
this.filter = name => /^extension\/license(\.(md|txt))?$/i.test(name);
this.expectedLicenseName = 'LICENSE, LICENSE.md, or LICENSE.txt';
this.filter = name => /^extension\/licen[cs]e(\.(md|txt))?$/i.test(name);
} else {
this.expectedLicenseName = match[1];
const regexp = new RegExp('^extension/' + match[1] + '$');
Expand Down
26 changes: 26 additions & 0 deletions src/test/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,32 @@ describe('toVsixManifest', () => {
});
});

it('should automatically detect misspelled license files', () => {
const manifest = {
name: 'test',
publisher: 'mocha',
version: '0.0.1',
description: 'test extension',
engines: Object.create(null),
};

const files = [{ path: 'extension/LICENCE.md', contents: '' }];

return _toVsixManifest(manifest, files)
.then(xml => parseXmlManifest(xml))
.then(result => {
assert.ok(result.PackageManifest.Metadata[0].License);
assert.strictEqual(result.PackageManifest.Metadata[0].License.length, 1);
assert.strictEqual(result.PackageManifest.Metadata[0].License[0], 'extension/LICENCE.md');
assert.strictEqual(result.PackageManifest.Assets[0].Asset.length, 2);
assert.strictEqual(
result.PackageManifest.Assets[0].Asset[1].$.Type,
'Microsoft.VisualStudio.Services.Content.License'
);
assert.strictEqual(result.PackageManifest.Assets[0].Asset[1].$.Path, 'extension/LICENCE.md');
});
});

it('should add an icon metadata tag', () => {
const manifest = {
name: 'test',
Expand Down

0 comments on commit 701a450

Please sign in to comment.