Skip to content

Commit

Permalink
Throw error if provided readmePath or provided changelogPath could no…
Browse files Browse the repository at this point in the history
…t be found
  • Loading branch information
benibenj committed Jul 17, 2024
1 parent f55228d commit ff9391d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,14 @@ export abstract class MarkdownProcessor extends BaseProcessor {
private gitHubIssueLinking: boolean;
private gitLabIssueLinking: boolean;

protected filesProcessed: number = 0;

constructor(
manifest: Manifest,
private name: string,
filePath: string,
private assetType: string,
options: IPackageOptions = {}
protected options: IPackageOptions = {}
) {
super(manifest);

Expand All @@ -761,6 +763,7 @@ export abstract class MarkdownProcessor extends BaseProcessor {
if (!this.regexp.test(filePath)) {
return Promise.resolve(file);
}
this.filesProcessed++;

this.assets.push({ type: this.assetType, path: filePath });

Expand Down Expand Up @@ -962,6 +965,13 @@ export class ReadmeProcessor extends MarkdownProcessor {
options
);
}

override async onEnd(): Promise<void> {
if (this.options.readmePath && this.filesProcessed === 0) {
util.log.error(`The provided readme file (${this.options.readmePath}) could not be found.`);
process.exit(1);
}
}
}

export class ChangelogProcessor extends MarkdownProcessor {
Expand All @@ -974,6 +984,13 @@ export class ChangelogProcessor extends MarkdownProcessor {
options
);
}

override async onEnd(): Promise<void> {
if (this.options.changelogPath && this.filesProcessed === 0) {
util.log.error(`The provided changelog file (${this.options.changelogPath}) could not be found.`);
process.exit(1);
}
}
}

export class LicenseProcessor extends BaseProcessor {
Expand Down Expand Up @@ -1943,7 +1960,7 @@ export async function ls(options: ILSOptions = {}): Promise<void> {
}

/**
* Prints the packaged files of an extension.
* Prints the packaged files of an extension. And ensures .vscodeignore and files property in package.json are used correctly.
*/
export async function printAndValidatePackagedFiles(files: IFile[], cwd: string, manifest: Manifest, options: IPackageOptions): Promise<void> {
// Warn if the extension contains a lot of files
Expand Down

0 comments on commit ff9391d

Please sign in to comment.