Skip to content

Commit

Permalink
Add support for --no-increment
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Aug 10, 2021
1 parent ecd4374 commit 5333778
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ class ConventionalChangelog extends Plugin {
}

async getChangelog(latestVersion) {
const { increment, isPreRelease, preReleaseId } = this.config.getContext('version');
const version = await this.getRecommendedVersion({ increment, latestVersion, isPreRelease, preReleaseId });
this.setContext({ version });
if (!this.config.isIncrement) {
this.setContext({ version: latestVersion });
} else {
const { increment, isPreRelease, preReleaseId } = this.config.getContext('version');
const version = await this.getRecommendedVersion({ increment, latestVersion, isPreRelease, preReleaseId });
this.setContext({ version });
}
return this.generateChangelog();
}

Expand Down Expand Up @@ -56,10 +60,12 @@ class ConventionalChangelog extends Plugin {

getChangelogStream(opts = {}) {
const { version } = this.getContext();
const previousTag = this.config.getContext('latestTag');
const tagTemplate = this.options.tagName || ((previousTag || '').match(/^v/) ? 'v${version}' : '${version}');
const currentTag = tagTemplate.replace('${version}', version);
const options = Object.assign({}, opts, this.options);
const { isIncrement } = this.config;
const { latestTag, secondLatestTag, tagTemplate } = this.config.getContext();
const currentTag = isIncrement ? tagTemplate.replace('${version}', version) : latestTag;
const previousTag = isIncrement ? latestTag : secondLatestTag;
const releaseCount = opts.releaseCount === 0 ? 0 : isIncrement ? 1 : 2;
const options = Object.assign({}, { releaseCount }, this.options);
const context = { version, previousTag, currentTag };
const debug = this.config.isDebug ? this.debug : null;
const gitRawCommitsOpts = { debug };
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
"devDependencies": {
"bron": "^1.1.1",
"proxyquire": "^2.1.0",
"release-it": "^14.8.0",
"release-it": "^14.11.1",
"sinon": "^11.1.1"
},
"peerDependencies": {
"release-it": "^14.8.0"
"release-it": "^14.11.1"
},
"engines": {
"node": ">=10"
Expand Down

0 comments on commit 5333778

Please sign in to comment.