fix(fund): support funding string shorthand#472
Conversation
In the approved RFC it was documented that `npm fund` should also support a shorthand version of the `funding` property using only a string instead of an object. This commit fixes it and adds tests to ensure its behavior.
|
I tried this and discovered it didn't work. Also, what about multiple values? Should/could it accept an array too? |
@ljharb multiple values are outside of the scope of the approved RFC 😬 |
In the approved RFC it was documented that `npm fund` should also support a shorthand version of the `funding` property using only a string instead of an object. This commit fixes it and adds tests to ensure its behavior. PR-URL: #472 Credit: @ Close: #472 Reviewed-by: @claudiahdz
|
Gotcha - given that packages have multiple authors, and a single author can have multiple funding options (i have GitHub sponsors and tidelift, for example) - it’d be great to add that. I’ll try to find time to write an RFC, if someone doesn’t beat me to it. |
|
oh yeah 🙏 please do, btw we have the OpenRFC call happening today |
| function retrieveFunding (funding) { | ||
| return typeof funding === 'string' | ||
| ? { | ||
| url: funding |
There was a problem hiding this comment.
nit: I would change this syntax to a one liner; { url: funding }. When I read this now it makes me think it's a block scope and something interesting is happening.
Overview
In the approved RFC it was documented that
npm fundshould also support a shorthand version of thefundingproperty using only a string instead of an object.✏️ Changes
fundingbehavior to normalize a string argument into valid info🔗 References
🔍 Testing
Manual testing:
In a folder with a given
package.json:{ "name": "foo", "version": "1.0.0", "funding": "http://example.com" }Running
npm fundshould output:✅ This change has unit test coverage
✅ This change has integration test coverage
🔥 Rollback
This can be reverted at any time