From 45fcad547e9034d55b257bbd362054847eac41cd Mon Sep 17 00:00:00 2001 From: Tom Chen Date: Sat, 25 Nov 2017 15:44:31 +0800 Subject: [PATCH] feat(format-commit-message): support multiple %s in the message --- lib/format-commit-message.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/format-commit-message.js b/lib/format-commit-message.js index 06b8702fe..b79ad2eb3 100644 --- a/lib/format-commit-message.js +++ b/lib/format-commit-message.js @@ -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) }