Skip to main content
Version: 1.3.0

API

Methods​

generateLicenseFile Async​

generateLicenseFile(pathToPackageJson: string, outputPath: string, lineEnding?: "windows" | "posix"): 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?: "windows" | "posix" - Will use the system default if omitted

Returns

Promise<void>


getLicenseFileText Async​

getLicenseFileText(pathToPackageJson: string, lineEnding?: "windows" | "posix"): 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?: "windows" | "posix" - 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.