diff --git a/ghost/release-utils/README.md b/ghost/release-utils/README.md index 3ab0082f8d..f7790359ee 100644 --- a/ghost/release-utils/README.md +++ b/ghost/release-utils/README.md @@ -75,14 +75,17 @@ releaseUtils username: String, token: String, }, - changelogPath: String [Path on Disk], + changelogPath: String [Path on Disk] OR Array[{ + changelogPath: String [Path on Disk], + content: Array [optional] + }], gistUrl: String [optional], preRelease: Boolean [optional, Default: false], draft: Boolean [optional, Default: true], filterEmojiCommits: Boolean [optional, Default: true], content: Array [optional] }); - + releaseUtils .releases .uploadZip({ diff --git a/ghost/release-utils/lib/releases.js b/ghost/release-utils/lib/releases.js index d533f9b7d6..513ba3261e 100644 --- a/ghost/release-utils/lib/releases.js +++ b/ghost/release-utils/lib/releases.js @@ -7,25 +7,25 @@ const request = require('request'); const localUtils = require('./utils'); -function appendChangelog(options) { +function getFinalChangelog(options) { let filterEmojiCommits = true; let changelog = fs.readFileSync(options.changelogPath).toString('utf8').split(os.EOL); - let body = []; + let finalChangelog = []; if (options.hasOwnProperty('filterEmojiCommits')) { filterEmojiCommits = options.filterEmojiCommits; } // @NOTE: optional array of string lines, which we pre-pend if (options.hasOwnProperty('content') && _.isArray(options.content)) { - body = body.concat(options.content); + finalChangelog = finalChangelog.concat(options.content); } if (filterEmojiCommits) { changelog = localUtils.filterEmojiCommits(changelog); } - body = body.concat(changelog); - return body; + finalChangelog = finalChangelog.concat(changelog); + return finalChangelog; } module.exports.create = (options = {}) => { @@ -52,13 +52,14 @@ module.exports.create = (options = {}) => { } let body = []; - // CASE: changelogPath can be array of paths with content or single path + // CASE: changelogPath can be array of paths with content if (_.isArray(options.changelogPath)) { - options.changelogPath.forEach((changelogOptions) => { - body.concat(appendChangelog(changelogOptions)); + options.changelogPath.forEach((opts) => { + body = body.concat(getFinalChangelog(opts)); }); } else { - body.concat(appendChangelog(options)); + // CASE: changelogPath can be a single path(For backward compatibility) + body = body.concat(getFinalChangelog(options)); } // CASE: clean before upload