AceMetrix / bower-license

Generates a list of bower dependencies
Apache License 2.0
15 stars 29 forks source link

Tolerate object-valued bower license property #17

Open pkaminski opened 8 years ago

pkaminski commented 8 years ago

I found at least one Bower package (serialized-lru-cache) that defines its license as:

  "license": {
    "type": "MIT",
    "url": "http://github.com/jmendiara/serialized-lru-cache/raw/master/LICENSE"
  },

No idea if it's spec-compliant or not, but it will crash bower-license and it's a simple fix, so...


This change is Reviewable

mojoaxel commented 8 years ago

I think this is a "bug" in the bower-config of serialized-lru-cache. This type of license definition is not in the spec. This issue should be fixed there and not here. Thanks anyway for finding and reporting!

anacronw commented 8 years ago

I agree, I don't think the library should be parsing arbitrary specs, but the crashing is not good.

I think what makes sense is simply to check for type:

if (typeof bowerData.license === 'string'){
  moduleInfo.licenses = moduleInfo.licenses.concat(bowerData.license)
}
pkaminski commented 8 years ago

OK, I opened a PR against serialized-lru-cache: https://github.com/jmendiara/serialized-lru-cache/pull/1

FWIW, the spec you pointed to also allows an array of strings for the license value, so the type check should probably allow for that.

mojoaxel commented 4 years ago

Fixed in https://github.com/jmendiara/serialized-lru-cache/pull/1 @badunk Can be closed here!