API
Methods
generateLicenseFile Async
generateLicenseFile(pathToPackageJson: string, outputPath: string, options?: GenerateLicenseFileOptions): Promise<void>
Scans the project found at the given path and creates a license file at the given output location
Parameters
pathToPackageJson: string- A path to the package.json for the projectoutputPath: string- A file path for the resulting license fileoptions?: GenerateLicenseFileOptions- Additional options for the license file generation
Returns
Promise<void>
getLicenseFileText Async
getLicenseFileText(pathToPackageJson: string, options?: GetLicenseFileTextOptions): Promise<string>
Scans the project found at the given path and returns a string containing the licenses for all the dependencies
Parameters
pathToPackageJson: string- A path to the package.json for the projectoptions?: GetLicenseFileTextOptions- Additional options for the license text generation
Returns
Promise<string> - A promise that resolves to the license file text
getProjectLicenses Async
getProjectLicenses(pathToPackageJson: string, options?: GetProjectLicensesOptions): Promise<ILicense[]>
Scans the project found at the given path and returns an array of objects each containing the details of an identified license and the dependencies it pertains to.
Parameters
pathToPackageJson: string- A path to the package.json for the projectoptions?: GetProjectLicensesOptions- Additional options for the license discovery
Returns
Promise<ILicense[]> - Array of ILicense objects, each containing the license content and respective dependencies
Models
ILicense
Contains the content of a given license and the list of dependencies it pertains to. It is returned from getProjectLicenses.
Properties
-
content: string- Body of the license. -
dependencies: string[]- List of node packages that this license applies to.
GenerateLicenseFileOptions
Additional options for the license file generation. Can be optionally passed into generateLicenseFile.
Properties
-
lineEnding: "lf" | "crlf"- Specify the line ending to use in the generated license file: either "lf" or "crlf". Leave undefined to use the system default -
replace: Record<string, string>- A map of packages-to-file-paths containing content that should be used instead of the package's license content -
exclude: string[]- Packages to exclude from the generated license file -
append: string[]- File paths to read in and append to the bottom of the generated license file
GetLicenseFileTextOptions
Additional options for the license text generation. Can be optionally passed into getLicenseFileText.
Properties
-
lineEnding: "lf" | "crlf"- Specify the line ending to use in the generated license file: either "lf" or "crlf". Leave undefined to use the system default -
replace: Record<string, string>- A map of packages-to-file-paths containing content that should be used instead of the package's license content -
exclude: string[]- Packages to exclude from the generated license file -
append: string[]- File paths to read in and append to the bottom of the generated license file
GetProjectLicensesOptions
Additional options for the license discovery. Can be optionally passed into getProjectLicenses.
Properties
-
replace: Record<string, string>- A map of packages-to-file-paths containing content that should be used instead of the package's license content -
exclude: string[]- Packages to exclude from the generated license file