mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
fix: cleanup table footer (#341)
This commit is contained in:
parent
8fc7c7e689
commit
0be7a63481
3 changed files with 56 additions and 9 deletions
|
@ -18,9 +18,6 @@ These people contributed to the project:
|
||||||
<td align=\\"center\\">Jeroen Engels is awesome!</td>
|
<td align=\\"center\\">Jeroen Engels is awesome!</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
|
||||||
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- markdownlint-restore -->
|
<!-- markdownlint-restore -->
|
||||||
|
@ -68,6 +65,34 @@ These people contributed to the project:
|
||||||
Thanks a lot everyone!"
|
Thanks a lot everyone!"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`replace the content between the ALL-CONTRIBUTORS-LIST tags by a table of contributors without linkToUsage 1`] = `
|
||||||
|
"# project
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
These people contributed to the project:
|
||||||
|
<!-- ALL-CONTRIBUTORS-LIST:START -->
|
||||||
|
<!-- prettier-ignore-start -->
|
||||||
|
<!-- markdownlint-disable -->
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
|
||||||
|
<td align=\\"center\\">Divjot Singh is awesome!</td>
|
||||||
|
<td align=\\"center\\">Jeroen Engels is awesome!</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- markdownlint-restore -->
|
||||||
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||||
|
|
||||||
|
Thanks a lot everyone!"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`split contributors into multiples lines when there are too many 1`] = `
|
exports[`split contributors into multiples lines when there are too many 1`] = `
|
||||||
"# project
|
"# project
|
||||||
|
|
||||||
|
@ -92,9 +117,6 @@ These people contributed to the project:
|
||||||
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
|
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
|
||||||
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- markdownlint-restore -->
|
<!-- markdownlint-restore -->
|
||||||
|
|
|
@ -47,7 +47,24 @@ test('replace the content between the ALL-CONTRIBUTORS-LIST tags by a table of c
|
||||||
const {kentcdodds, bogas04} = contributors
|
const {kentcdodds, bogas04} = contributors
|
||||||
const {options, jfmengels, content} = fixtures()
|
const {options, jfmengels, content} = fixtures()
|
||||||
const contributorList = [kentcdodds, bogas04, jfmengels]
|
const contributorList = [kentcdodds, bogas04, jfmengels]
|
||||||
const result = generate(Object.assign(options, { linkToUsage: true }), contributorList, content)
|
const result = generate(
|
||||||
|
Object.assign(options, {linkToUsage: true}),
|
||||||
|
contributorList,
|
||||||
|
content,
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result).toMatchSnapshot()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('replace the content between the ALL-CONTRIBUTORS-LIST tags by a table of contributors without linkToUsage', () => {
|
||||||
|
const {kentcdodds, bogas04} = contributors
|
||||||
|
const {options, jfmengels, content} = fixtures()
|
||||||
|
const contributorList = [kentcdodds, bogas04, jfmengels]
|
||||||
|
const result = generate(
|
||||||
|
Object.assign(options, {linkToUsage: false}),
|
||||||
|
contributorList,
|
||||||
|
content,
|
||||||
|
)
|
||||||
|
|
||||||
expect(result).toMatchSnapshot()
|
expect(result).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
@ -81,7 +98,11 @@ test('split contributors into multiples lines when there are too many with linkT
|
||||||
kentcdodds,
|
kentcdodds,
|
||||||
kentcdodds,
|
kentcdodds,
|
||||||
]
|
]
|
||||||
const result = generate(Object.assign(options, { linkToUsage: true }), contributorList, content)
|
const result = generate(
|
||||||
|
Object.assign(options, {linkToUsage: true}),
|
||||||
|
contributorList,
|
||||||
|
content,
|
||||||
|
)
|
||||||
|
|
||||||
expect(result).toMatchSnapshot()
|
expect(result).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
|
@ -62,6 +62,7 @@ function formatFooter(options) {
|
||||||
|
|
||||||
function generateContributorsList(options, contributors) {
|
function generateContributorsList(options, contributors) {
|
||||||
const tableFooter = formatFooter(options)
|
const tableFooter = formatFooter(options)
|
||||||
|
let tableFooterContent = ''
|
||||||
|
|
||||||
return _.flow(
|
return _.flow(
|
||||||
_.sortBy(contributor => {
|
_.sortBy(contributor => {
|
||||||
|
@ -76,7 +77,10 @@ function generateContributorsList(options, contributors) {
|
||||||
_.map(formatLine),
|
_.map(formatLine),
|
||||||
_.join('\n </tr>\n <tr>\n '),
|
_.join('\n </tr>\n <tr>\n '),
|
||||||
newContent => {
|
newContent => {
|
||||||
return `\n<table>\n <tbody>\n <tr>\n ${newContent}\n </tr>\n </tbody>\n <tfoot>\n ${tableFooter}\n </tfoot>\n</table>\n\n`
|
if (options.linkToUsage) {
|
||||||
|
tableFooterContent = ` <tfoot>\n ${tableFooter}\n </tfoot>\n`
|
||||||
|
}
|
||||||
|
return `\n<table>\n <tbody>\n <tr>\n ${newContent}\n </tr>\n </tbody>\n${tableFooterContent}</table>\n\n`
|
||||||
},
|
},
|
||||||
)(contributors)
|
)(contributors)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue