From 8528a8f2840d7a73c8dbcd614aba17540ff494c9 Mon Sep 17 00:00:00 2001 From: koeneijkemans Date: Sun, 5 Jul 2020 09:32:42 +0200 Subject: [PATCH] improve the regex + return first result --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 4161914..12be7bf 100644 --- a/index.js +++ b/index.js @@ -27,12 +27,14 @@ async function getBranchName() { } }; - await execlib.exec('git', ['branch'], options); + await execlib.exec('git', ['branch', '--show-current'], options); return output; } function extractVersion(branch) { - const regexp = /^([0-9]\.[0-9]\.[0-9])|([0-9]\.[0-9])|([0-9])$/; - return branch.match(regexp); + const regexp = /([0-9]\.[0-9]\.[0-9])|([0-9]\.[0-9])|([0-9])/g; + const matches = branch.match(regexp); + + return matches ? matches.shift() : null; } \ No newline at end of file