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
24 changes: 20 additions & 4 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,22 @@ const yargv = yargs
.alias('v', 'version')
.version()
.recommendCommands()
.command('generate', `Generate the list of contributors\n\nUSAGE: all-contributors generate`)
.command('add', `Add a new contributor\n\nUSAGE: all-contributors add <username> <comma-separated contributions>`)
.command('init', `Prepare the project to be used with this tool\n\nUSAGE: all-contributors init`)
.command(
'generate',
`Generate the list of contributors\n\nUSAGE: all-contributors generate`,
)
.command(
'add',
`Add a new contributor\n\nUSAGE: all-contributors add <username> <comma-separated contributions>`,
)
.command(
'init',
`Prepare the project to be used with this tool\n\nUSAGE: all-contributors init`,
)
.command(
'check',
`Compare contributors from the repository with the ones credited in .all-contributorsrc'\n\nUSAGE: all-contributors check`)
`Compare contributors from the repository with the ones credited in .all-contributorsrc'\n\nUSAGE: all-contributors check`,
)
.boolean('commit')
.default('files', ['README.md'])
.default('contributorsPerLine', 7)
Expand All @@ -37,6 +47,12 @@ const yargv = yargs
description:
'Sort the list of contributors alphabetically in the generated list',
})
.option('contributorsSortLocale', {
type: 'string',
default: undefined,
description:
'Locale to use for sorting the contributors alphabetically in the generated list',
})
.default('contributors', [])
.default('config', defaultRCFile)
.config('config', configPath => {
Expand Down
15 changes: 9 additions & 6 deletions src/generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,21 @@ function generateContributorsList(options, contributors) {
let tableFooterContent = ''

return _.flow(
_.sortBy(contributor => {
c => {
if (options.contributorsSortAlphabetically) {
return contributor.name
c.sort((a, b) =>
a.name.localeCompare(b.name, options.contributorsSortLocale),
)
}
}),
return c
},
_.map(function formatEveryContributor(contributor) {
return formatContributor(options, contributor)
}),
_.chunk(options.contributorsPerLine),
_.map((currentLineContributors) => formatLine(
options, currentLineContributors
)),
_.map(currentLineContributors =>
formatLine(options, currentLineContributors),
),
_.join('\n </tr>\n <tr>\n '),
newContent => {
if (options.linkToUsage) {
Expand Down