Skip to content

Commit

Permalink
feat(format-commit-message): support multiple %s in the message
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchentw committed Nov 28, 2017
1 parent b37bc66 commit 45fcad5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/format-commit-message.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const util = require('util')

module.exports = function (msg, newVersion) {
return String(msg).indexOf('%s') !== -1 ? util.format(msg, newVersion) : msg
module.exports = function (rawMsg, newVersion) {
const message = String(rawMsg)
const matchCount = (message.match(/%s/g) || []).length
const args = Array(1 + matchCount)
args[0] = message
args.fill(newVersion, 1, args.length)
return util.format.apply(util, args)
}

0 comments on commit 45fcad5

Please sign in to comment.