Skip to content

Commit

Permalink
feat: replace all placeholder occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
lekterable committed May 9, 2020
1 parent 73f2ecb commit d0e7248
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/utils/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const generateReleased = (previousVersion, config) =>

if (
isUnreleased &&
line === config.releaseFormat.replace('%version%', previousVersion)
line === config.releaseFormat.replace(/%version%/g, previousVersion)
) {
isUnreleased = false

Expand All @@ -47,7 +47,7 @@ export const generateChangelog = (version, groups, config) => {
const release = getCommitDetails(group.release)
const releaseVersion = (release && release.message) || version
const title = releaseVersion
? config.releaseFormat.replace('%version%', releaseVersion)
? config.releaseFormat.replace(/%version%/g, releaseVersion)
: config.unreleasedFormat

let groupChangelog = title + '\n\n'
Expand Down Expand Up @@ -84,6 +84,6 @@ export const generateChangelog = (version, groups, config) => {

export const generateLine = ({ message, hash }, config) =>
config.lineFormat
.replace('%HASH%', hash)
.replace('%hash%', hash.slice(0, 8))
.replace('%message%', message)
.replace(/%HASH%/g, hash)
.replace(/%hash%/g, hash.slice(0, 8))
.replace(/%message%/g, message)
7 changes: 5 additions & 2 deletions src/utils/changelog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,15 @@ describe('changelog', () => {
})

it('should generate line with custom config', () => {
const config = { ...defaultConfig, lineFormat: '* %message%' }
const config = {
...defaultConfig,
lineFormat: '* %message% %hash% %hash%'
}
const mockedInput = {
message: 'generate changelog',
hash: 'b2f5901922505efbfb6dd684252e8df0cdffeeb2'
}
const mockedOutput = '* generate changelog'
const mockedOutput = '* generate changelog b2f59019 b2f59019'

const line = generateLine(mockedInput, config)

Expand Down

0 comments on commit d0e7248

Please sign in to comment.