Skip to content

Commit

Permalink
Merge pull request #48 from rwjblue/work-without-tagname
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue authored Apr 27, 2020
2 parents 2b24a56 + 3083a1c commit adb8be2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 3 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ module.exports = class LernaChangelogGeneratorPlugin extends Plugin {

get nextVersion() {
let { version } = this.config.getContext();
let nextVersion = this.getTagNameFromVersion(version);

let tagName = this.config.getContext('git.tagName');
let nextVersion = tagName ? format(tagName, { version }) : version;

return nextVersion;
}
Expand All @@ -33,12 +35,6 @@ module.exports = class LernaChangelogGeneratorPlugin extends Plugin {
return this.changelog;
}

getTagNameFromVersion(version) {
let tagName = this.config.getContext('git.tagName');

return format(tagName, { version });
}

async getTagForHEAD() {
try {
return await this.exec('git describe --tags --abbrev=0', { options: { write: false } });
Expand Down
6 changes: 5 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ test('it invokes lerna-changelog', async (t) => {
});

test('it honors custom git.tagName formatting', async (t) => {
let plugin = buildPlugin();
let infile = tmp.fileSync().name;
let plugin = buildPlugin({ infile });

plugin.config.setContext({ git: { tagName: 'v${version}' } });

Expand All @@ -105,6 +106,9 @@ test('it honors custom git.tagName formatting', async (t) => {
['git describe --tags --abbrev=0', { write: false }],
[`${LERNA_PATH} --next-version=Unreleased --from=v1.0.0`, { write: false }],
]);

const changelog = fs.readFileSync(infile, { encoding: 'utf8' });
t.is(changelog, `### v1.0.1 (2020-03-18)\n\nThe changelog\n\n`);
});

test('it sets the changelog without version information onto the config', async (t) => {
Expand Down

0 comments on commit adb8be2

Please sign in to comment.