license-checker icon indicating copy to clipboard operation
license-checker copied to clipboard

feat: Implement --excludeScopes=@scope1;@scope2 option

Open ChrisHubinger opened this issue 5 years ago • 5 comments

This option makes the license-checker ignore all packages that are in one of the semicolon-separated list of scopes.

ChrisHubinger avatar Oct 30 '19 08:10 ChrisHubinger

Any chance to get this merged? This is very useful.

szymn avatar Nov 19 '19 04:11 szymn

Yes, we need this.

kenhuang avatar Jan 30 '20 02:01 kenhuang

@davglass it would be really great to have this feature merged. Can you accept this merge please?

DennisKae avatar Apr 17 '20 13:04 DennisKae

@davglass this would be very helpful. Are you able to look at PRs these days?

b-zurg avatar Jun 07 '20 10:06 b-zurg

In the meantime I'm using the license checker with my own custom typescript script and wrote this little set of helper functions that does basically what I needed:

const formatDependencyList = (packages: Record<string, string>, orgPrefix: string) =>
  Object.entries(packages)
    .filter(([name]) => name.startsWith(orgPrefix))
    .map(([name, version]) => `${name}@${version}`, []);

const extractOrgPackageExclusion = (prefix: string) =>
  [
    ...formatDependencyList(packageJson.dependencies, prefix),
    ...formatDependencyList(packageJson.devDependencies, prefix),
  ].join(";");

const excludePackages = extractOrgPackageExclusion("@myorganization");

Then you simply pass in excludePackages as one of the checker options and it does the trick. Pretty nifty!

The major benefit of this approach is that it's resilient to version number changes or any package addition and simply looks for a scope. 🎉

b-zurg avatar Aug 08 '20 12:08 b-zurg