Skip to main content
Version: 2.0.0

API

Methods​

generateLicenseFile Async​

Overload 1 of 2

generateLicenseFile(pathToPackageJson: string, outputPath: string, lineEnding?: "crlf" | "lf"): 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 project

  • outputPath: string - A file path for the resulting license file

  • lineEnding?: "crlf" | "lf" - Will use the system default if omitted

Returns

Promise<void>


getLicenseFileText Async​

Overload 1 of 2

getLicenseFileText(pathToPackageJson: string, lineEnding?: "crlf" | "lf"): 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 project

  • lineEnding?: "crlf" | "lf" - Will use the system default if omitted

Returns

Promise<string> - A promise that resolves to the license file text


getProjectLicenses Async​

getProjectLicenses(pathToPackageJson: string): 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 project

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.