Skip to content

Commit

Permalink
Merge pull request #1062 from microsoft/benibenj/following-goat
Browse files Browse the repository at this point in the history
Fix readme-path handling
  • Loading branch information
benibenj authored Oct 7, 2024
2 parents ba070b6 + b7830c3 commit c37ddd0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ export abstract class MarkdownProcessor extends BaseProcessor {
if (!this.regexp.test(filePath)) {
return Promise.resolve(file);
}

return await this.processFile(file, filePath);
}

protected async processFile(file: IFile, filePath: string): Promise<IFile> {
this.filesProcessed++;

this.assets.push({ type: this.assetType, path: filePath });
Expand Down Expand Up @@ -970,6 +975,11 @@ export class ReadmeProcessor extends MarkdownProcessor {
);
}

override async processFile(file: IFile): Promise<IFile> {
file.path = 'extension/readme.md';
return await super.processFile(file, file.path);
}

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.`);
Expand All @@ -989,6 +999,11 @@ export class ChangelogProcessor extends MarkdownProcessor {
);
}

override async processFile(file: IFile): Promise<IFile> {
file.path = 'extension/changelog.md';
return await super.processFile(file, file.path);
}

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.`);
Expand Down
4 changes: 2 additions & 2 deletions src/test/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ describe('toVsixManifest', () => {
result.PackageManifest.Assets[0].Asset[1].$.Type,
'Microsoft.VisualStudio.Services.Content.Details'
);
assert.strictEqual(result.PackageManifest.Assets[0].Asset[1].$.Path, 'extension/foo/readme-foo.md');
assert.strictEqual(result.PackageManifest.Assets[0].Asset[1].$.Path, 'extension/readme.md');
});
});

Expand Down Expand Up @@ -752,7 +752,7 @@ describe('toVsixManifest', () => {
result.PackageManifest.Assets[0].Asset[1].$.Type,
'Microsoft.VisualStudio.Services.Content.Changelog'
);
assert.strictEqual(result.PackageManifest.Assets[0].Asset[1].$.Path, 'extension/foo/changelog-foo.md');
assert.strictEqual(result.PackageManifest.Assets[0].Asset[1].$.Path, 'extension/changelog.md');
});
});

Expand Down

0 comments on commit c37ddd0

Please sign in to comment.