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
.vscode
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',
[
'[![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](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)',
'<!-- ALL-CONTRIBUTORS-BADGE:END -->',
'<!-- 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-)\n',
'<!-- 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)',
].join(''),
'',
@ -157,9 +157,9 @@ test('replace all-contributors badge if present', () => {
'Badges',
[
'[![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](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)',
'<!-- ALL-CONTRIBUTORS-BADGE:END -->',
'<!-- 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-)\n',
'<!-- 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)',
].join(''),
'',

View file

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