-
Notifications
You must be signed in to change notification settings - Fork 145
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
PR for Issue6: projectOwner & projectName is not set in .all-contributorsrc file. #80
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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we catch if we're going to throw anyways? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for else here too
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same remarks for else
s
i did the changes, i will add the tests soon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Just one thing
src/util/config-file.js
Outdated
@@ -14,6 +14,12 @@ function readConfig(configPath) { | |||
} | |||
|
|||
function writeConfig(configPath, content) { | |||
if (content.projectOwner === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure will get on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this aaaa
here is a typo?
Other than that, this looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but this is a node package isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for being late.
It seems that this file was removed in this 152a1fe commit. I retested everything
@@ -1,15 +1,43 @@ | |||
import configFile from '../config-file' | |||
|
|||
const absentFile = './abc' | |||
const expected = `Configuration file not found: ${absentFile}` | |||
const absentConfileFileExpected = `Configuration file not found: ${absentFile}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed this as, we have more test with expected
in this file now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Thanks so much!
* docs: update README.md * docs: update .all-contributorsrc
What:
Why:
How:
config-file
before config is written into a json filecheck
before url is being constructedcheck
to handle errorChecklist: