Skip to content

Commit 77a014f

Browse files
jerodsantoKent C. Dodds
authored andcommitted
feat: throw a helpful error when unknown contribution type is provided (#41)
* throw a helpful error when unknown contribution type is provided * Add @jerodsanto as a contributor
1 parent e1e7ead commit 77a014f

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@
6262
"code",
6363
"doc"
6464
]
65+
},
66+
{
67+
"login": "jerodsanto",
68+
"name": "Jerod Santo",
69+
"avatar_url": "https://avatars3.githubusercontent.com/u/8212?v=3",
70+
"profile": "https://jerodsanto.net",
71+
"contributions": [
72+
"code"
73+
]
6574
}
6675
]
6776
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# all-contributors-cli
22

33
[![version](https://img.shields.io/npm/v/all-contributors-cli.svg)](http://npm.im/all-contributors-cli)
4-
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors)
4+
[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors)
55

66
This is a tool to help automate adding contributor acknowledgements according to the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.
77

@@ -93,8 +93,8 @@ These are the keys you can specify:
9393
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
9494

9595
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
96-
| [<img src="https://avatars.githubusercontent.com/u/3869412?v=3" width="100px;"/><br /><sub>Jeroen Engels</sub>](https://github.com/jfmengels)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) | [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com/)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) | [<img src="https://avatars.githubusercontent.com/u/14871650?v=3" width="100px;"/><br /><sub>João Guimarães</sub>](https://github.com/jccguimaraes)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jccguimaraes) | [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/22768990?v=3" width="100px;"/><br /><sub>Itai Steinherz</sub>](https://github.com/itaisteinherz)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz) [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz) | [<img src="https://avatars.githubusercontent.com/u/5701162?v=3" width="100px;"/><br /><sub>Alex Jover</sub>](https://github.com/alexjoverm)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm) [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm) |
97-
| :---: | :---: | :---: | :---: | :---: | :---: |
96+
| [<img src="https://avatars.githubusercontent.com/u/3869412?v=3" width="100px;"/><br /><sub>Jeroen Engels</sub>](https://github.com/jfmengels)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) [⚠️](https://github.com/jfmengels/all-contributors-cli/commits?author=jfmengels) | [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](http://kentcdodds.com/)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=kentcdodds) | [<img src="https://avatars.githubusercontent.com/u/14871650?v=3" width="100px;"/><br /><sub>João Guimarães</sub>](https://github.com/jccguimaraes)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jccguimaraes) | [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/22768990?v=3" width="100px;"/><br /><sub>Itai Steinherz</sub>](https://github.com/itaisteinherz)<br />[📖](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz) [💻](https://github.com/jfmengels/all-contributors-cli/commits?author=itaisteinherz) | [<img src="https://avatars.githubusercontent.com/u/5701162?v=3" width="100px;"/><br /><sub>Alex Jover</sub>](https://github.com/alexjoverm)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm) [📖](https://github.com/jfmengels/all-contributors-cli/commits?author=alexjoverm) | [<img src="https://avatars3.githubusercontent.com/u/8212?v=3" width="100px;"/><br /><sub>Jerod Santo</sub>](https://jerodsanto.net)<br />[💻](https://github.com/jfmengels/all-contributors-cli/commits?author=jerodsanto) |
97+
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
9898
<!-- ALL-CONTRIBUTORS-LIST:END -->
9999

100100
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification.

lib/generate/format-contribution-type.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ function getType(options, contribution) {
1212

1313
module.exports = function formatContribution(options, contributor, contribution) {
1414
var type = getType(options, contribution);
15+
16+
if (!type) {
17+
throw new Error('Unknown contribution type ' + contribution + ' for contributor ' + contributor.login);
18+
}
19+
1520
var templateData = {
1621
symbol: type.symbol,
1722
contributor: contributor,

lib/generate/format-contribution-type.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,9 @@ test('should be able to override existing templates', t => {
116116
url: 'www.foo.bar'
117117
}), '[:web:](www.foo.bar)');
118118
});
119+
120+
test('should throw a helpful error on unknown type', t => {
121+
const contributor = contributors.kentcdodds;
122+
const {options} = fixtures();
123+
t.throws(() => formatContributionType(options, contributor, 'docs'), 'Unknown contribution type docs for contributor kentcdodds');
124+
});

0 commit comments

Comments
 (0)