Skip to content

Commit 125ba00

Browse files
committed
[added] special case for 'mt-changelog' package
with 'mt-changelog' package it uses './bin/changelog'
1 parent 9618ec7 commit 125ba00

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/release.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ const devDepsNode = npmjson.devDependencies;
2323

2424
//------------------------------------------------------------------------------
2525
// check if one of 'rf-changelog' or 'mt-changelog' is used by project
26-
const isCommitsChangelogUsed = devDepsNode &&
26+
let isCommitsChangelogUsed = devDepsNode &&
2727
devDepsNode['rf-changelog'] || devDepsNode['mt-changelog'];
2828
if (isCommitsChangelogUsed && !which('changelog')) {
2929
printErrorAndExit('The "[rf|mt]-changelog" package is present in "devDependencies", but it is not installed.');
3030
}
3131

32+
const isWithinMtChangelog = npmjson.name === 'mt-changelog';
33+
isCommitsChangelogUsed = isCommitsChangelogUsed || isWithinMtChangelog;
34+
3235
//------------------------------------------------------------------------------
3336
// options
3437
const configOptions = npmjson['release-script'] || {};
@@ -193,8 +196,10 @@ function release({ type, preid }) {
193196
const versionAndNotes = notesForRelease = notesForRelease ? `${vVersion} ${notesForRelease}` : vVersion;
194197

195198
// generate changelog
199+
// within mt-changelog at this stage `./bin/changelog` is already built and tested
200+
const changelogCmd = isWithinMtChangelog ? './bin/changelog' : 'changelog';
196201
if (isCommitsChangelogUsed) {
197-
run(`changelog --title="${versionAndNotes}" --out ${changelog}`);
202+
run(`${changelogCmd} --title="${versionAndNotes}" --out ${changelog}`);
198203
safeRun(`git add ${changelog}`);
199204
console.log('Generated Changelog'.cyan);
200205
}
@@ -204,7 +209,7 @@ function release({ type, preid }) {
204209
// tag and release
205210
console.log('Tagging: '.cyan + vVersion.green);
206211
if (isCommitsChangelogUsed) {
207-
notesForRelease = run(`changelog --title="${versionAndNotes}" -s`);
212+
notesForRelease = run(`${changelogCmd} --title="${versionAndNotes}" -s`);
208213
safeRun(`changelog --title="${versionAndNotes}" -s | git tag -a -F - ${vVersion}`);
209214
} else {
210215
safeRun(`git tag -a --message="${versionAndNotes}" ${vVersion}`);

0 commit comments

Comments
 (0)