Skip to content

Commit 45fcad5

Browse files
committed
feat(format-commit-message): support multiple %s in the message
1 parent b37bc66 commit 45fcad5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/format-commit-message.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const util = require('util')
22

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

0 commit comments

Comments
 (0)