Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: all-contributors/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.23.0
Choose a base ref
...
head repository: all-contributors/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.23.1
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Oct 6, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0be7a63 View commit details
Showing with 56 additions and 9 deletions.
  1. +28 −6 src/generate/__tests__/__snapshots__/index.js.snap
  2. +23 −2 src/generate/__tests__/index.js
  3. +5 −1 src/generate/index.js
34 changes: 28 additions & 6 deletions src/generate/__tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
@@ -18,9 +18,6 @@ These people contributed to the project:
<td align=\\"center\\">Jeroen Engels is awesome!</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<!-- markdownlint-restore -->
@@ -68,6 +65,34 @@ These people contributed to the project:
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`] = `
"# project
@@ -92,9 +117,6 @@ These people contributed to the project:
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<!-- markdownlint-restore -->
25 changes: 23 additions & 2 deletions src/generate/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -47,7 +47,24 @@ test('replace the content between the ALL-CONTRIBUTORS-LIST tags by a table of c
const {kentcdodds, bogas04} = contributors
const {options, jfmengels, content} = fixtures()
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()
})
@@ -81,7 +98,11 @@ test('split contributors into multiples lines when there are too many with linkT
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()
})
6 changes: 5 additions & 1 deletion src/generate/index.js
Original file line number Diff line number Diff line change
@@ -62,6 +62,7 @@ function formatFooter(options) {

function generateContributorsList(options, contributors) {
const tableFooter = formatFooter(options)
let tableFooterContent = ''

return _.flow(
_.sortBy(contributor => {
@@ -76,7 +77,10 @@ function generateContributorsList(options, contributors) {
_.map(formatLine),
_.join('\n </tr>\n <tr>\n '),
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)
}