Skip to content

Commit

Permalink
[added] special case for 'mt-changelog' package
Browse files Browse the repository at this point in the history
with 'mt-changelog' package it uses './bin/changelog'
  • Loading branch information
AlexKVal committed Sep 15, 2015
1 parent 9618ec7 commit 125ba00
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ const devDepsNode = npmjson.devDependencies;

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

const isWithinMtChangelog = npmjson.name === 'mt-changelog';
isCommitsChangelogUsed = isCommitsChangelogUsed || isWithinMtChangelog;

//------------------------------------------------------------------------------
// options
const configOptions = npmjson['release-script'] || {};
Expand Down Expand Up @@ -193,8 +196,10 @@ function release({ type, preid }) {
const versionAndNotes = notesForRelease = notesForRelease ? `${vVersion} ${notesForRelease}` : vVersion;

// generate changelog
// within mt-changelog at this stage `./bin/changelog` is already built and tested
const changelogCmd = isWithinMtChangelog ? './bin/changelog' : 'changelog';
if (isCommitsChangelogUsed) {
run(`changelog --title="${versionAndNotes}" --out ${changelog}`);
run(`${changelogCmd} --title="${versionAndNotes}" --out ${changelog}`);
safeRun(`git add ${changelog}`);
console.log('Generated Changelog'.cyan);
}
Expand All @@ -204,7 +209,7 @@ function release({ type, preid }) {
// tag and release
console.log('Tagging: '.cyan + vVersion.green);
if (isCommitsChangelogUsed) {
notesForRelease = run(`changelog --title="${versionAndNotes}" -s`);
notesForRelease = run(`${changelogCmd} --title="${versionAndNotes}" -s`);
safeRun(`changelog --title="${versionAndNotes}" -s | git tag -a -F - ${vVersion}`);
} else {
safeRun(`git tag -a --message="${versionAndNotes}" ${vVersion}`);
Expand Down

0 comments on commit 125ba00

Please sign in to comment.