Skip to content

Commit 588ad79

Browse files
feat: warn users about missing LICENSE (#628)
* feat:warn users about missing LICENSE * updated expectedLicenseName default name Co-authored-by: João Moreno <[email protected]> * fixed failling test Fixed test [toVsixManifest] should automatically detect license files: * Update src/package.ts * Update src/package.ts * Update src/package.ts * Update src/package.ts Co-authored-by: João Moreno <[email protected]>
1 parent a92b2f5 commit 588ad79

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/package.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ export class ChangelogProcessor extends MarkdownProcessor {
813813

814814
class LicenseProcessor extends BaseProcessor {
815815
private didFindLicense = false;
816+
private expectedLicenseName: string;
816817
filter: (name: string) => boolean;
817818

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

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

849852
return Promise.resolve(file);
850853
}
854+
855+
async onEnd(): Promise<void> {
856+
if (!this.didFindLicense) {
857+
util.log.warn(`${this.expectedLicenseName} not found`);
858+
859+
if (!/^y$/i.test(await util.read('Do you want to continue? [y/N] '))) {
860+
throw new Error('Aborted');
861+
}
862+
}
863+
}
851864
}
852865

853866
class IconProcessor extends BaseProcessor {

0 commit comments

Comments
 (0)