Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/generate/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,20 @@ test('validate if cell width attribute is floored correctly', () => {

expect(result).toMatchSnapshot()
})

test('inject the table when the ALL-CONTRIBUTORS-LIST tag starts the file', () => {
const {kentcdodds, bogas04} = contributors
const {options} = fixtures()
const contributorList = [kentcdodds, bogas04]
const content = [
'<!-- ALL-CONTRIBUTORS-LIST:START -->FOO BAR BAZ<!-- ALL-CONTRIBUTORS-LIST:END -->',
'',
'Thanks a lot everyone!',
].join('\n')

const result = generate(options, contributorList, content)

expect(result).toContain('<table>')
expect(result).toContain('<!-- ALL-CONTRIBUTORS-LIST:END -->')
expect(result).not.toContain('FOO BAR BAZ')
})
2 changes: 1 addition & 1 deletion src/generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function injectListBetweenTags(newContent) {
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
'\n<!-- prettier-ignore-start -->',
'\n<!-- markdownlint-disable -->',
newContent.replace('\n', `\n${' '.repeat(nbSpaces - 1)}`),
newContent.replace('\n', `\n${' '.repeat(Math.max(0, nbSpaces - 1))}`),
'<!-- markdownlint-restore -->',
'\n<!-- prettier-ignore-end -->',
'\n\n',
Expand Down