diff options
author | Ruy Adorno <ruyadorno@hotmail.com> | 2019-11-20 00:32:57 +0300 |
---|---|---|
committer | Michael Perrotte <mike@npmjs.com> | 2019-12-03 20:13:43 +0300 |
commit | 1c65d26ac9f10ac0037094c207d216fbf0e969bf (patch) | |
tree | d3588f74b51b66f024df0c9f0e66d9a0cf695bb4 /lib/fund.js | |
parent | e4b97962e5fce0d49beb541ce5a0f96aee0525de (diff) |
fix(fund): open url for string shorthand
Trying to open url for a package that is using the string shorthand is
currently broken using: `npm fund <pkg>`
This commit fixes the issue and adds the missing unit and integration
tests covering that usecase.
Fixes #498
PR-URL: https://github.com/npm/cli/pull/501
Credit: @ruyadorno
Close: #501
Reviewed-by: @mikemimik
Diffstat (limited to 'lib/fund.js')
-rw-r--r-- | lib/fund.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/fund.js b/lib/fund.js index 4981e4615..00954c844 100644 --- a/lib/fund.js +++ b/lib/fund.js @@ -14,7 +14,7 @@ const readShrinkwrap = require('./install/read-shrinkwrap.js') const mutateIntoLogicalTree = require('./install/mutate-into-logical-tree.js') const output = require('./utils/output.js') const openUrl = require('./utils/open-url.js') -const { getFundingInfo, validFundingUrl } = require('./utils/funding.js') +const { getFundingInfo, retrieveFunding, validFundingUrl } = require('./utils/funding.js') const FundConfig = figgyPudding({ browser: {}, // used by ./utils/open-url @@ -132,7 +132,7 @@ function printHuman (fundingInfo, opts) { function openFundingUrl (packageName, cb) { function getUrlAndOpen (packageMetadata) { const { funding } = packageMetadata - const { type, url } = funding || {} + const { type, url } = retrieveFunding(funding) || {} const noFundingError = new Error(`No funding method available for: ${packageName}`) noFundingError.code = 'ENOFUND' |