Skip to content
13 changes: 13 additions & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ export class ChangelogProcessor extends MarkdownProcessor {

class LicenseProcessor extends BaseProcessor {
private didFindLicense = false;
private expectedLicenseName: string;
filter: (name: string) => boolean;

constructor(manifest: Manifest) {
Expand All @@ -821,8 +822,10 @@ class LicenseProcessor extends BaseProcessor {
const match = /^SEE LICENSE IN (.*)$/.exec(manifest.license || '');

if (!match || !match[1]) {
this.expectedLicenseName = 'LICENSE.md or LICENSE.txt';
this.filter = name => /^extension\/license(\.(md|txt))?$/i.test(name);
} else {
this.expectedLicenseName = match[1];
const regexp = new RegExp('^extension/' + match[1] + '$');
this.filter = regexp.test.bind(regexp);
}
Expand All @@ -848,6 +851,16 @@ class LicenseProcessor extends BaseProcessor {

return Promise.resolve(file);
}

async onEnd(): Promise<void> {
if (!this.didFindLicense) {
util.log.warn(`${this.expectedLicenseName} not found`);

if (!/^y$/i.test(await util.read('Do you want to continue? [y/N] '))) {
throw new Error('Aborted');
}
}
}
}

class IconProcessor extends BaseProcessor {
Expand Down