diff --git a/src/generate/__tests__/index.js b/src/generate/__tests__/index.js index 8b247f9a..33a06c87 100644 --- a/src/generate/__tests__/index.js +++ b/src/generate/__tests__/index.js @@ -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 = [ + 'FOO BAR BAZ', + '', + 'Thanks a lot everyone!', + ].join('\n') + + const result = generate(options, contributorList, content) + + expect(result).toContain('') + expect(result).toContain('') + expect(result).not.toContain('FOO BAR BAZ') +}) diff --git a/src/generate/index.js b/src/generate/index.js index 07ad73f7..61082c59 100644 --- a/src/generate/index.js +++ b/src/generate/index.js @@ -42,7 +42,7 @@ function injectListBetweenTags(newContent) { previousContent.slice(0, endOfOpeningTagIndex + closingTag.length), '\n', '\n', - newContent.replace('\n', `\n${' '.repeat(nbSpaces - 1)}`), + newContent.replace('\n', `\n${' '.repeat(Math.max(0, nbSpaces - 1))}`), '', '\n', '\n\n',