@semantic-release/changelog
Advanced tools
Comparing version 2.0.3 to 2.1.0
@@ -16,2 +16,10 @@ const url = require('url'); | ||
}), | ||
EINVALIDCHANGELOGTITLE: ({changelogTitle}) => ({ | ||
message: 'Invalid `changelogTitle` option.', | ||
details: `The [changelogTitle option](${linkify( | ||
'README.md#options' | ||
)}) option, if defined, must be a non empty \`String\`. | ||
Your configuration for the \`changelogTitle\` option is \`${changelogTitle}\`.`, | ||
}), | ||
}; |
@@ -5,3 +5,3 @@ const {readFile, writeFile, ensureFile} = require('fs-extra'); | ||
module.exports = async (pluginConfig, notes, logger) => { | ||
const {changelogFile} = resolveConfig(pluginConfig); | ||
const {changelogFile, changelogTitle} = resolveConfig(pluginConfig); | ||
@@ -17,4 +17,11 @@ if (notes) { | ||
} | ||
await writeFile(changelogFile, `${notes.trim()}\n${currentFile ? `\n${currentFile}\n` : ''}`); | ||
const currentContent = | ||
changelogTitle && currentFile.startsWith(changelogTitle) | ||
? currentFile.slice(changelogTitle.length).trim() | ||
: currentFile; | ||
const content = `${notes.trim()}\n${currentContent ? `\n${currentContent}\n` : ''}`; | ||
await writeFile(changelogFile, changelogTitle ? `${changelogTitle}\n\n${content}` : content); | ||
} | ||
}; |
const {isUndefined} = require('lodash'); | ||
module.exports = ({changelogFile}) => ({ | ||
module.exports = ({changelogFile, changelogTitle}) => ({ | ||
changelogFile: isUndefined(changelogFile) ? 'CHANGELOG.md' : changelogFile, | ||
changelogTitle, | ||
}); |
@@ -7,3 +7,3 @@ const {isString, isUndefined} = require('lodash'); | ||
module.exports = pluginConfig => { | ||
const {changelogFile} = resolveConfig(pluginConfig); | ||
const {changelogFile, changelogTitle} = resolveConfig(pluginConfig); | ||
const errors = []; | ||
@@ -15,2 +15,6 @@ | ||
if (!isUndefined(changelogTitle) && !(isString(changelogTitle) && changelogTitle.trim())) { | ||
errors.push(getError('EINVALIDCHANGELOGTITLE', {changelogTitle})); | ||
} | ||
if (errors.length > 0) { | ||
@@ -17,0 +21,0 @@ throw new AggregateError(errors); |
{ | ||
"name": "@semantic-release/changelog", | ||
"description": "Set of semantic-release plugins for creating or updating a changelog file", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"author": "Pierre Vanduynslager (https://github.com/pvdlg)", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -24,6 +24,8 @@ # @semantic-release/changelog | ||
| Options | Description | Default | | ||
|-----------------|-----------------------------|----------------| | ||
| `changelogFile` | File path of the changelog. | `CHANGELOG.md` | | ||
| Options | Description | Default | | ||
|------------------|-----------------------------|----------------| | ||
| `changelogFile` | File path of the changelog. | `CHANGELOG.md` | | ||
| `changelogTitle` | Title in the changelog. | None | | ||
### Usage | ||
@@ -30,0 +32,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9564
90
62