From a6567cce05e8364f55756be4ec2c6eb6a171320b Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 16 May 2016 23:07:50 +0300 Subject: [PATCH] fix: don't mutate shield options --- index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 81eb361..89b6be1 100644 --- a/index.js +++ b/index.js @@ -18,11 +18,9 @@ function shieldman (service, opts) { return undefined } - if (!shieldTemplate.hasBranchVersion) { - delete opts.branch - } + const branch = shieldTemplate.hasBranchVersion ? opts.branch : null - const linkTemplate = opts.branch && shieldTemplate.branchLink || shieldTemplate.link + const linkTemplate = branch && shieldTemplate.branchLink || shieldTemplate.link return { text: shieldTemplate.text, @@ -31,7 +29,7 @@ function shieldman (service, opts) { } function getShieldImage (imagePath) { - const branchSuffix = opts.branch && ('/' + opts.branch) || '' + const branchSuffix = branch && ('/' + branch) || '' return `https://img.shields.io/${format(imagePath, opts)}` + `${branchSuffix}.${ext}${opts.style ? `?style=${opts.style}` : ''}` }