Skip to content
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

Support for old package.json license structure #5

Closed
0xs opened this issue Oct 15, 2016 · 8 comments
Closed

Support for old package.json license structure #5

0xs opened this issue Oct 15, 2016 · 8 comments
Assignees

Comments

@0xs
Copy link

0xs commented Oct 15, 2016

I know that according to the current package.json format specification the license info should always be a string. Unfortunately many packages still use the old notation of license.type shown here. Since I should show these licenses too it would be great if there was support for listing them too.

@xz64 xz64 self-assigned this Oct 15, 2016
@xz64
Copy link
Owner

xz64 commented Oct 22, 2016

I have pushed a change to the dev branch but haven't tested it. Please try the dev branch and see if that works out for you.

@grauwoelfchen
Copy link

Hi,

Thank you for nice tool. I like it!
I tried your dev branch. But I think that this line also should be changed for moduleInfo.license.

var isMatching = this.pattern.test(moduleInfo.license) || !moduleInfo.license && this.includeUndefined;

So, I've just tried to extract license before this pattern matching, and updated to support following old 2 styles.

license: {
  type: '...'
, url: '...'
}

Array but it contains only one license.

e.g. respond.js

licenses: [
  { 'type': '...'
  , 'url': '...'
  }
]

I'll attach a link of a small patch. could you please check this :)
https://gist.github.com/grauwoelfchen/d01899aa46c10f079dfdb8833a57df56

If license is also cached like packagejson, it might be better.

@xz64
Copy link
Owner

xz64 commented Nov 7, 2016

Thanks @grauwoelfchen . I've incorporated your patch and force pushed a new change to dev branch. Caching the license would be ideal, but it should be OK to not cache it for now. Please check out the dev branch and let me know if you have any other thoughts.

@grauwoelfchen
Copy link

Thank you @xz64 for quick response . You've also added improvements and tests :)
I will try dev branch!

If this plugin could support user to choose a license from packages which have muliple licenses in this old style licenses in package.json, it would be perfect to me!

@xz64
Copy link
Owner

xz64 commented Nov 20, 2016

@grauwoelfchen I have pushed a change to the dev branch which allows you to use a licenseTypeOverrides option. You can check the README to see how to use it. Please let me know if this works out for you.

@grauwoelfchen
Copy link

@xz64 Thank you su much! licenseTypeOverrides and licenseTypeCache look very nice :) I will try it.

xz64 added a commit that referenced this issue Nov 23, 2016
@xz64 xz64 closed this as completed in 53cf3a3 Nov 23, 2016
@xz64
Copy link
Owner

xz64 commented Nov 23, 2016

Published this feature in v0.4.0.

@grauwoelfchen
Copy link

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants