提取 NPM 包许可证。这是 Dav Glass 原始(但已放弃)许可检查器的增强和更新版本。
提取 NPM 包许可证。这是 Dav Glass 原始(但已放弃)许可检查器的增强和更新版本。
6.0.0 is the final release of license-checker-rseidelsohn.
We're moving everything over to @lizenz/checker. Its initial 1.0.0
is a 100% compatible drop-in replacement. Further development, updates, and features will happen there, as well.
This (admittedly oddly-named) package started as a fork of Dav Glass' "O.G." license-checker as the original hasn't been maintained for quite some time. The goal was to keep it up to date, to fix bugs and maybe to add a few new features here and there. Then reality kicked in, and this package has been sitting somewhat stale for a while, too . There are other forks out there, as well. Most are pretty stale. Some have seen some activity. But overall, the landscape is a bit complicated right now.
We decided to fix this:
I changed the original exclude argument to excludeLicenses in order to prevent confusion and better align it with
the excludePackages argument. Also, the argument includeLicenses has been added for listing only packages that
include the licenses listed.
Ever needed to see all the license info for a module and its dependencies?
It's this easy:
npm install -g license-checker-rseidelsohn
mkdir foo
cd foo
npm install yui-lint
license-checker-rseidelsohnYou should see something like this:
…An asterisk next to a license name means that it was deduced from another file than package.json (README, LICENSE, COPYING, ...).
Take a look at the detailed changelog or at the releases page.
The following options are command-line flags for the license-checker-rseidelsohn executable. Some of the same
behavior is also available through the programmatic runLicenseCheck API. See Programmatic API for the
supported runLicenseCheck options and their types.
--angularCli is just a synonym for --plainVertical--clarificationsFile [filepath] A file that describe the license clarifications for each package. See
clarificationExample.json. Any field available to the customFormat option can be
clarified. The clarifications file can also be used to specify a subregion of a package's license file (instead of
reading the entire file)--clarificationsMatchAll [boolean] This optional new feature is still lacking a description - to be done--color colorize terminal tree output--csv output in csv format--csvComponentPrefix prefix column for component in csv format--customPath to add a custom Format file in JSON--depth [number] look for "number" of levels of dependencies - overrides the ambiguously named "--direct" option--development only show development dependencies.--direct [boolean|number] look for direct dependencies only if "true" or look for "number" of levels of dependencies--excludeLicenses [list] exclude modules which licenses are in the comma-separated list from the output--excludePackages [list] restrict output to the packages (either "package@fullversion" or "package@majorversion" or
only "package") not in the semicolon-separated list--excludePackagesStartingWith [list] exclude modules which names start with the semicolon-separated list from the
output (useful for excluding modules from a specific vendor and such). Example:
--excludePackagesStartingWith "webpack;@types;@babel"--excludePrivatePackages restrict output to not include any package marked as private--failOn [list] fail (exit with code 1) on the first occurrence of the licenses of the semicolon-separated list--files [path] copy all license files to path and rename them to module-name@version-LICENSE.txt--help (-h) The text you are reading right now :)--includeLicenses [list] include only modules which licenses are in the comma-separated list from the output--includePackages [list] restrict output to the packages (either "package@fullversion" or "package@majorversion" or
only "package") in the semicolon-separated list--json output in json format--limitAttributes [list] limit the attributes to be output--markdown output in markdown format--nopeer skip peer dependencies in output--onlyAllow [list] fail (exit code 1) on the first occurrence of the licenses not in the semicolon-separated list--onlyunknown only list packages with unknown or guessed licenses--out [filepath] write the data to a specific file--plainVertical output license info in plain vertical format like Angular CLI does--production only show production dependencies.--relativeLicensePath output the location of the license files as relative paths--relativeModulePath output the location of the module files as relative paths--start [filepath] path of the initial JSON to look for--summary output a summary of the license usage--unknown report guessed licenses as unknown licenses--version (-v) The current versionA list of licenses is the simplest way to describe what you want to exclude.
You can use valid SPDX identifiers. You can use valid SPDX expressions like MIT OR X11.
You can use non-valid SPDX identifiers, like Public Domain, since npm does support some license strings that are not
SPDX identifiers.
license-checker-rseidelsohn --json > /path/to/licenses.json
license-checker-rseidelsohn --csv --out /path/to/licenses.csv
license-checker-rseidelsohn --unknown
license-checker-rseidelsohn --customPath customFormatExample.json
license-checker-rseidelsohn --excludeLicenses 'MIT, MIT OR X11, BSD, ISC'
license-checker-rseidelsohn --includePackages '[email protected];[email protected];[email protected]'
license-checker-rseidelsohn --excludePackages 'internal-1;internal-2'
license-checker-rseidelsohn --onlyunknownThe --clarificationsFile option can be used to provide custom processing instructions on a per-package basis. The
format is as so:
…version can either be an exact version or a semver range, multiple ranges are supported for a single package, for
example:
{
"package_name@^1": {
// Any field available in customFormat can be clarified
"licenses": "GPL",
// ... other fields, see above
},
"package_name@^2": {
// Any field available in customFormat can be clarified
"licenses": "MIT",
// ... other fields, see above
},
}For overlapping ranges, the first matching entry is used.
The --clarificationsMatchAll option, when enabled, raises an error if not all specified clarifications were used, it
is off by default.
A custom format can be provided on the CLI with --customPath, or programmatically with customFormat. It can be used
with CSV to specify the columns. Note that the first column, module_name, will always be used.
When used with JSON format, it will add the specified items to the usual ones. It does not limit JSON output to only
those items. In particular, licenses is core result data and is still emitted even if customFormat.licenses is
false.
To limit JSON output to a fixed set of attributes, use --limitAttributes.
The available items are the following:
You can also give default values for each item. See an example in customFormatExample.json.
Note that outputting the license text is not recommended with Markdown formatting, as it can be very long and does not work well with Markdown lists.
The documented programmatic entrypoint is runLicenseCheck(opts).
import { runLicenseCheck } from 'license-checker-rseidelsohn';
const packages = await runLicenseCheck({ start: '/path/to/start/looking' });
// The sorted package data as an Object
console.log(packages);If an error occurred, the returned promise rejects. If the checker ran successfully, the promise resolves to an object keyed by package name plus version.
Bugfix note: library code no longer terminates the host process for license policy or clarification failures. These
failures are now reported via rejected runLicenseCheck promise. CLI behavior remains unchanged.
Supported runLicenseCheck options (alphabetically):
| Option | Type | Description |
|---|---|---|
clarificationsFile |
string |
Path to a JSON file with package-specific license clarifications. |
clarificationsMatchAll |
boolean |
Fail the run if any clarification entry was not used. |
color |
boolean |
Colorize license strings in the returned data where the checker emits colorized license values. |
csv |
boolean |
Format file output as CSV when out is set. |
csvComponentPrefix |
string |
Add a component prefix column to CSV output. |
customFormat |
Record |
Custom output fields and default values. |
customPath |
string |
Path to a JSON file that defines a custom output format. |
development |
boolean |
Only include development dependencies. |
direct |
number |
Limit dependency recursion by depth. Use 0 for direct dependencies only. |
excludeLicenses |
string |
暂无开放 Issues,或尚未同步最近议题。