Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage multiple authors #147

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/questions/author-github.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { cleanSocialNetworkUsername } = require('../utils')

module.exports = projectInfos => ({
type: 'input',
message: '👤 GitHub username (use empty value to skip)',
message: '👤 GitHub username (comma to split, empty to skip)',
name: 'authorGithubUsername',
default: projectInfos.githubUsername,
filter: cleanSocialNetworkUsername
Expand Down
2 changes: 1 addition & 1 deletion src/questions/author-github.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('askAuthorGithub', () => {

expect(result).toEqual({
type: 'input',
message: '👤 GitHub username (use empty value to skip)',
message: '👤 GitHub username (comma to split, empty to skip)',
name: 'authorGithubUsername',
default: githubUsername,
filter: expect.any(Function)
Expand Down
2 changes: 1 addition & 1 deletion src/questions/author-name.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = projectInfos => ({
type: 'input',
message: '👤 Author name',
message: '👤 Author name (use comma if several)',
name: 'authorName',
default: projectInfos.author
})
2 changes: 1 addition & 1 deletion src/questions/author-name.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('askAuthorName', () => {

expect(result).toEqual({
type: 'input',
message: '👤 Author name',
message: '👤 Author name (use comma if several)',
name: 'authorName',
default: author
})
Expand Down
2 changes: 1 addition & 1 deletion src/questions/author-twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { cleanSocialNetworkUsername } = require('../utils')

module.exports = () => ({
type: 'input',
message: '🐦 Twitter username (use empty value to skip)',
message: '🐦 Twitter username (comma to split, empty to skip)',
name: 'authorTwitterUsername',
filter: cleanSocialNetworkUsername
})
2 changes: 1 addition & 1 deletion src/questions/author-twitter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('askAuthorTwitter', () => {

expect(result).toEqual({
type: 'input',
message: '🐦 Twitter username (use empty value to skip)',
message: '🐦 Twitter username (comma to split, empty to skip)',
name: 'authorTwitterUsername',
filter: expect.any(Function)
})
Expand Down
36 changes: 26 additions & 10 deletions templates/default-no-html.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](<%= repositoryUrl %>/graphs/commit-activity)
<% } -%>
<% if (licenseName) { -%>
[![License: <%= licenseName %>](https://img.shields.io/<%= isGithubRepos ? `github/license/${authorGithubUsername}/${projectName}` : `badge/License-${licenseName}-yellow.svg` %>)](<%= licenseUrl ? licenseUrl : '#' %>)
[![License: <%= licenseName %>](https://img.shields.io/<%= isGithubRepos ? `github/license/${authorGithubUsername.split(',')[0]}/${projectName}` : `badge/License-${licenseName}-yellow.svg` %>)](<%= licenseUrl ? licenseUrl : '#' %>)
<% } -%>
<% if (authorTwitterUsername) { -%>
[![Twitter: <%= authorTwitterUsername %>](https://img.shields.io/twitter/follow/<%= authorTwitterUsername %>.svg?style=social)](https://twitter.com/<%= authorTwitterUsername %>)
<% authorTwitterUsername.split(',').forEach(e => { -%>
[![Twitter: <%= e.trim() %>](https://img.shields.io/twitter/follow/<%= e.trim() %>.svg?style=social)](https://twitter.com/<%= e.trim() %>)
<% }) -%>
<% } -%>
<% if (projectDescription) { -%>

Expand Down Expand Up @@ -67,16 +69,28 @@
```
<% } -%>
<% if (authorName || authorTwitterUsername || authorGithubUsername) { -%>
<% if (authorName.split(',').length > 1) { -%>

## Authors

<% } else { -%>

## Author
<% if (authorName) { %>
👤 **<%= authorName %>**

<% } -%>
<% const names = authorName.split(',') -%>
<% const twitters = authorTwitterUsername.split(',') -%>
<% const githubs = authorGithubUsername.split(',') -%>
<% for (var i = 0; i < names.length; i++) { -%>
<% if (names[i]) { -%>
👤 **<%= names[i].trim() %>**
<% } %>
<% if (authorTwitterUsername) { -%>
* Twitter: [@<%= authorTwitterUsername %>](https://twitter.com/<%= authorTwitterUsername %>)
<% if (twitters[i]) { -%>
* Twitter: [@<%= twitters[i].trim() %>](https://twitter.com/<%= twitters[i].trim() %>)
<% } -%>
<% if (githubs[i]) { -%>
* Github: [@<%= githubs[i].trim() %>](https://github.com/<%= githubs[i].trim() %>)
<% } -%>
<% if (authorGithubUsername) { -%>
* Github: [@<%= authorGithubUsername %>](https://github.com/<%= authorGithubUsername %>)
<% } -%>
<% } -%>
<% if (contributingUrl) { -%>
Expand All @@ -101,9 +115,11 @@ Give a ⭐️ if this project helped you!
## 📝 License

<% if (authorName && authorGithubUsername) { -%>
Copyright © <%= currentYear %> [<%= authorName %>](https://github.com/<%= authorGithubUsername %>).

<% const authors = authorName.split(',') -%>
<% const githubs = authorGithubUsername.split(',') -%>
Copyright © <%= currentYear %> [<%= authors[0].trim() %>](https://github.com/<%= githubs[0].trim() %>)<% for (var i = 1; i < authors.length; i++) { if (authors[i] && githubs[i]) { -%>, [<%= authors[i].trim() %>](https://github.com/<%= githubs[i].trim() %>)<%_ }} _%>.
<% } -%>

This project is [<%= licenseName %>](<%= licenseUrl %>) licensed.
<% } -%>

Expand Down
34 changes: 24 additions & 10 deletions templates/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
<% } -%>
<% if (licenseName) { -%>
<a href="<%= licenseUrl ? licenseUrl : '#' %>" target="_blank">
<img alt="License: <%= licenseName %>" src="https://img.shields.io/<%= isGithubRepos ? `github/license/${authorGithubUsername}/${projectName}` : `badge/License-${licenseName}-yellow.svg` %>" />
<img alt="License: <%= licenseName %>" src="https://img.shields.io/<%= isGithubRepos ? `github/license/${authorGithubUsername.split(',')[0]}/${projectName}` : `badge/License-${licenseName}-yellow.svg` %>" />
</a>
<% } -%>
<% if (authorTwitterUsername) { -%>
<a href="https://twitter.com/<%= authorTwitterUsername %>" target="_blank">
<img alt="Twitter: <%= authorTwitterUsername %>" src="https://img.shields.io/twitter/follow/<%= authorTwitterUsername %>.svg?style=social" />
<% authorTwitterUsername.split(',').forEach(e => { -%>
<a href="https://twitter.com/<%= e.trim() %>" target="_blank">
<img alt="Twitter: <%= e.trim() %>" src="https://img.shields.io/twitter/follow/<%= e.trim() %>.svg?style=social" />
</a>
<% }) -%>
<% } -%>
</p>
<% if (projectDescription) { -%>
Expand Down Expand Up @@ -79,16 +81,26 @@
```
<% } -%>
<% if (authorName || authorTwitterUsername || authorGithubUsername) { -%>
<% if (authorName.split(',').length > 1) { -%>

## Authors
<% } else { -%>

## Author
<% if (authorName) { %>
👤 **<%= authorName %>**
<% } -%>
<% const names = authorName.split(',') -%>
<% const twitters = authorTwitterUsername.split(',') -%>
<% const githubs = authorGithubUsername.split(',') -%>
<% for (var i = 0; i < names.length; i++) { -%>
<% if (names[i]) { %>
👤 **<%= names[i].trim() %>**
<% } %>
<% if (authorTwitterUsername) { -%>
* Twitter: [@<%= authorTwitterUsername %>](https://twitter.com/<%= authorTwitterUsername %>)
<% if (twitters[i]) { -%>
* Twitter: [@<%= twitters[i].trim() %>](https://twitter.com/<%= twitters[i].trim() %>)
<% } -%>
<% if (githubs[i]) { -%>
* Github: [@<%= githubs[i].trim() %>](https://github.com/<%= githubs[i].trim() %>)
<% } -%>
<% if (authorGithubUsername) { -%>
* Github: [@<%= authorGithubUsername %>](https://github.com/<%= authorGithubUsername %>)
<% } -%>
<% } -%>
<% if (contributingUrl) { -%>
Expand All @@ -112,7 +124,9 @@ Give a ⭐️ if this project helped you!
## 📝 License

<% if (authorName && authorGithubUsername) { -%>
Copyright © <%= currentYear %> [<%= authorName %>](https://github.com/<%= authorGithubUsername %>).<br />
<% const authors = authorName.split(',') -%>
<% const githubs = authorGithubUsername.split(',') -%>
Copyright © <%= currentYear %> [<%= authors[0].trim() %>](https://github.com/<%= githubs[0].trim() %>)<% for (var i = 1; i < authors.length; i++) { if (authors[i] && githubs[i]) { -%>, [<%= authors[i].trim() %>](https://github.com/<%= githubs[i].trim() %>)<%_ }} _%>.<br />
<% } -%>
This project is [<%= licenseName %>](<%= licenseUrl %>) licensed.
<% } -%>
Expand Down