Skip to content

Commit

Permalink
[#40] Fix finding CHANGELOG files from workspace folder
Browse files Browse the repository at this point in the history
  • Loading branch information
zero88 committed Aug 23, 2022
1 parent 61d866b commit 2e69888
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ChangelogOps {
async generate(latestTag: string, releaseTag: string, dryRun: boolean): Promise<GenerateResult> {
const commitMsg = `${this.config.commitMsg} ${releaseTag}`;
const workspace = readEnv('GITHUB_WORKSPACE');
const isExisted = await this.verifyExists(releaseTag);
const isExisted = await this.verifyExists(workspace, releaseTag);
if (isExisted) {
return { latestTag, releaseTag, commitMsg, generated: false };
}
Expand All @@ -92,7 +92,7 @@ export class ChangelogOps {
return { latestTag, releaseTag, commitMsg, generated: dockerRun.success };
}

async verifyExists(releaseTag: string): Promise<boolean> {
async verifyExists(workspace: string, releaseTag: string): Promise<boolean> {
const re = /((base|output)\s?=\s?)(.+)/;
const result: string[] = [];
await replaceInFile({
Expand All @@ -102,8 +102,7 @@ export class ChangelogOps {
return match;
},
});
const dir = path.dirname(this.config.configFile);
const files = (isEmpty(result) ? ['CHANGELOG.md'] : result).map(f => path.resolve(dir, f));
const files = (isEmpty(result) ? ['CHANGELOG.md'] : result).map(f => path.resolve(workspace, f));
return await replaceInFile(
{ files, from: releaseTag, dry: true, countMatches: true, allowEmptyPaths: true, to: match => match })
.then(rr => rr.some(r => r?.numMatches! > 0));
Expand Down

0 comments on commit 2e69888

Please sign in to comment.