PR for Issue6: projectOwner & projectName is not set in .all-contributorsrc file.#80
Conversation
2. added check for owner and name in getcontributionsfromgithub before constructing url
Codecov Report
@@ Coverage Diff @@
## master #80 +/- ##
==========================================
+ Coverage 53.54% 53.99% +0.44%
==========================================
Files 19 19
Lines 409 413 +4
Branches 66 68 +2
==========================================
+ Hits 219 223 +4
Misses 161 161
Partials 29 29
Continue to review full report at Codecov.
|
machour
left a comment
There was a problem hiding this comment.
Thank you @M-ZubairAhmed! Left you some comments.
Do you think you could add some tests for this?
src/util/check.js
Outdated
| body = JSON.parse(res.body) | ||
| contributorsIds = body.map(contributor => contributor.login) | ||
| } catch (error) { | ||
| throw new Error(error) |
There was a problem hiding this comment.
Why do we catch if we're going to throw anyways? 🤔
There was a problem hiding this comment.
oh ok should i use chalk to display the error
src/util/check.js
Outdated
| return getContributorsPage(url) | ||
| if (owner === '') { | ||
| throw new Error('Error! Project owner is not set in .all-contributorsrc') | ||
| } else if (name === '') { |
There was a problem hiding this comment.
ok, i will replace it with if
src/util/check.js
Outdated
| throw new Error('Error! Project owner is not set in .all-contributorsrc') | ||
| } else if (name === '') { | ||
| throw new Error('Error! Project name is not set in .all-contributorsrc ') | ||
| } else { |
src/util/config-file.js
Outdated
| throw new Error(`Error! Project Name is not set in ${configPath}`) | ||
| } else if (content.projectName === '') { | ||
| throw new Error(`Error! Project Name is not set in ${configPath}`) | ||
| } else { |
|
i did the changes, i will add the tests soon |
kentcdodds
left a comment
There was a problem hiding this comment.
Looking good! Just one thing
src/util/config-file.js
Outdated
| } | ||
|
|
||
| function writeConfig(configPath, content) { | ||
| if (content.projectOwner === '') { |
There was a problem hiding this comment.
Instead of '', why don't we do a simple falsy check? if (!content.projectOwner)
This has the added benefit of working if the value is set to null or undefined somehow.
We should do that for all the checks I think.
There was a problem hiding this comment.
@kentcdodds thank you for your comment, i however feel that it could be a big pr, would you like me to add that in the current pr?
There was a problem hiding this comment.
It's not an addition, it's simply a change to your addition. This change wont make the PR any bigger...
There was a problem hiding this comment.
sure will get on it
There was a problem hiding this comment.
i didnt knew this https://stackoverflow.com/a/8693015.
Thank you @kentcdodds
|
added changes as per @kentcdodds comment. Please @machour @kentcdodds review when you guys get time |
src/util/check.js
Outdated
| module.exports = function getContributorsFromGithub(owner, name) { | ||
| if (!owner) { | ||
| throw new Error( | ||
| `${owner} aaaaError! Project owner is not set in .all-contributorsrc`, |
There was a problem hiding this comment.
I'm guessing this aaaa here is a typo?
Other than that, this looks good!
There was a problem hiding this comment.
damn how did i miss that. Fixed it
src/util/check.js
Outdated
| @@ -0,0 +1,54 @@ | |||
| const pify = require('pify') | |||
There was a problem hiding this comment.
Sorry, it's been a little while, but why does this file exist? It doesn't appear to be in use anywhere in the project (other than tests)...
There was a problem hiding this comment.
Sorry but this is a node package isn't it?
There was a problem hiding this comment.
Sorry, I should have been more clear. I'm commenting on the file src/utils/check.js not pify.
There was a problem hiding this comment.
sorry for being late.
It seems that this file was removed in this 152a1fe commit. I retested everything
|
|
||
| const absentFile = './abc' | ||
| const expected = `Configuration file not found: ${absentFile}` | ||
| const absentConfileFileExpected = `Configuration file not found: ${absentFile}` |
There was a problem hiding this comment.
renamed this as, we have more test with expected in this file now.
kentcdodds
left a comment
There was a problem hiding this comment.
This looks good. Thanks so much!
* docs: update README.md * docs: update .all-contributorsrc
What:
Why:
How:
config-filebefore config is written into a json filecheckbefore url is being constructedcheckto handle errorChecklist: