fix: fix badge replacement (#232)

This commit is contained in:
Jake Bolam 2019-12-08 20:05:05 -05:00 committed by GitHub
parent 3382821641
commit dbb05a4dd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 7 deletions

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ package-lock.json
yarn.lock yarn.lock
.vscode .vscode
cache cache
.idea

2
.nvmrc
View file

@ -1 +1 @@
8.14.0 8.16.0

View file

@ -143,9 +143,9 @@ test('replace all-contributors badge if present', () => {
'Badges', 'Badges',
[ [
'[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)', '[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)',
'<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->', '<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n',
'[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)', '[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n',
'<!-- ALL-CONTRIBUTORS-BADGE:END -->', '<!-- ALL-CONTRIBUTORS-BADGE:END -->\n',
'[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)', '[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)',
].join(''), ].join(''),
'', '',
@ -157,9 +157,9 @@ test('replace all-contributors badge if present', () => {
'Badges', 'Badges',
[ [
'[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)', '[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)',
'<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->', '<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n',
'[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)', '[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n',
'<!-- ALL-CONTRIBUTORS-BADGE:END -->', '<!-- ALL-CONTRIBUTORS-BADGE:END -->\n',
'[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)', '[![version](https://img.shields.io/npm/v/all-contributors-cli.svg?style=flat-square)](http://npm.im/all-contributors-cli)',
].join(''), ].join(''),
'', '',

View file

@ -81,7 +81,9 @@ function replaceBadge(newContent) {
} }
return [ return [
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length), previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
'\n',
newContent, newContent,
'\n',
previousContent.slice(startOfClosingTagIndex), previousContent.slice(startOfClosingTagIndex),
].join('') ].join('')
} }