mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
feat: display a meaningful error when the config file is missing (#288)
* feat: display a meaningful error when the config file is missing ## What When you try to add a user with `.all-contributorsrc` missing, you will get a cryptic error message (see also all-contributors/all-contributors#378): ``` $ all-contributors add darekkay maintenance Cannot read property 'then' of null ``` This PR displays a meaningful error message in this case. ## Why So users know what's causing the problem. ## How Before a contribution is being added, the script checks whether the config file exists. If it doesn't, an error message is being displayed: ``` $ all-contributors add darekkay maintenance Configuration file not found: C:\projects\test\.all-contributorsrc ``` * docs: add darekkay as a contributor * refactor: fixed typos * docs(readme): table rectification Co-authored-by: Maximilian Berkmann <maxieberkmann@gmail.com>
This commit is contained in:
parent
24004d56b5
commit
d517440203
5 changed files with 15 additions and 4 deletions
|
@ -530,6 +530,15 @@
|
|||
"code",
|
||||
"test"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "darekkay",
|
||||
"name": "Darek Kay",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/3101914?v=4",
|
||||
"profile": "https://darekkay.com/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"skipCi": true
|
||||
|
|
|
@ -148,8 +148,9 @@ Thanks goes to these wonderful people
|
|||
<td align="center"><a href="https://www.linkedin.com/in/mloning/"><img src="https://avatars3.githubusercontent.com/u/21020482?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Markus Löning</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=mloning" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://dlaa.me/"><img src="https://avatars1.githubusercontent.com/u/1828270?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Anson</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/issues?q=author%3ADavidAnson" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=Favna" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://erekspeed.com"><img src="https://avatars3.githubusercontent.com/u/1176550?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Erek Speed</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=melink14" title="Code">💻</a></td>
|
||||
<td align="center"><a href="http://www.hirez.io"><img src="https://avatars1.githubusercontent.com/u/1430726?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shai Reznik</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/issues?q=author%3Ashairez" title="Bug reports">🐛</a> <a href="https://github.com/all-contributors/all-contributors-cli/commits?author=shairez" title="Code">💻</a> <a href="https://github.com/all-contributors/all-contributors-cli/commits?author=shairez" title="Tests">⚠️</a></td>
|
||||
<td align="center"><a href="https://darekkay.com/"><img src="https://avatars0.githubusercontent.com/u/3101914?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Darek Kay</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=darekkay" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://erekspeed.com"><img src="https://avatars3.githubusercontent.com/u/1176550?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Erek Speed</b></sub></a><br /><a href="https://github.com/all-contributors/all-contributors-cli/commits?author=melink14" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ function startGeneration(argv) {
|
|||
}
|
||||
|
||||
function addContribution(argv) {
|
||||
util.configFile.readConfig(argv.config) // ensure the config file exists
|
||||
const username = argv._[1] === undefined ? undefined : String(argv._[1])
|
||||
const contributions = argv._[2]
|
||||
// Add or update contributor in the config file
|
||||
|
|
|
@ -68,7 +68,7 @@ test('format contributor with pipes in their name', () => {
|
|||
expect(formatContributor(options, contributor)).toBe(expected)
|
||||
})
|
||||
|
||||
test('format contributor with no github account', () => {
|
||||
test('format contributor with no GitHub account', () => {
|
||||
const contributor = contributors.nologin
|
||||
const {options} = fixtures()
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ test('Throw error when missing enterprise authentication', async () => {
|
|||
)
|
||||
})
|
||||
|
||||
test('handle API rate github errors', async () => {
|
||||
test('handle API rate GitHub errors', async () => {
|
||||
const githubErrorMessage =
|
||||
"API rate limit exceeded for 0.0.0.0. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details."
|
||||
nock('https://api.github.com').get('/users/nodisplayname').reply(200, {
|
||||
|
@ -177,7 +177,7 @@ test('append http when no absolute link is provided', async () => {
|
|||
expect(info.profile).toBe('http://www.github.com/nodisplayname')
|
||||
})
|
||||
|
||||
test('retrieve user from a different github registry', async () => {
|
||||
test('retrieve user from a different GitHub registry', async () => {
|
||||
nock('http://github.myhost.com:3000/api/v3')
|
||||
.get('/users/nodisplayname')
|
||||
.reply(200, {
|
||||
|
|
Loading…
Reference in a new issue