Skip to main content
Version: 3.0.0

Config File

The generate-license-file CLI can be configured using a config file so that you don't need to re-enter the same config options every time. The config file also allows you to specify additional more complex options that are not available as CLI flags.

File Formats​

Config files can be called either .glf or .generatelicensefile and can be customised using the following options:

  • File name can optionally end with rc
  • Can be in a ./.config directory (no longer needs the . prefix on the file name)
  • Have the following file extensions: .json, jsonc, .json5, .yaml, .yml, .js, .cjs

E.g. .glf.json, .glfrc.yml, .generatelicensefile.jsonc, .config/glf.js, and more.

Config Options​

The file can contain all of the options that are available as CLI flags.

{
"inputs": ["./package.json"],
"output": "./THIRD-PARTY-LICENSES.txt",
"overwrite": true,
"eol": "lf",
"ci": true,
"no-spinner": true
}
Tip

JavaScript allows for more dynamic usages

module.exports = {
ci: process.env.CI === "true",
};

The more advanced features that a config file can contain allow you to edit the contents of the generated output file.

Append​

The append option allows you to append files to the end of the generated output file. This is useful if your project contains other types of licensed material other than node_modules dependencies that you want to include like fonts or images.

{
"append": ["./extra-licenses.txt"]
}

Replace​

The replace option allows you to replace the license content for a specific dependency. This is useful in situations like:

  • A dependency does not have its license file included in the published package
  • The license file is not in a standard format
  • The published package contains multiple license files and you want to pick a specific one

Packages can be specified using the format package@version or package, where the latter will match all versions of a given package. If both are specified, then the configuration with a matching version will take precedence.

tip

While it might be more convenient to use the package name without the version, it is recommended to use the version where possible to guarentee you always know exactly which package you are replacing the license for.

{
"replace": {
"lodash@1.2.3": "./licenses/lodash.txt",
"react@1.2.3": "./node_modules/react/LICENSE",
"axios": "./node_modules/axios/LICENSE"
}
}
When using pnpm, the way to reference a file in a node_module can look a little different
{
"replace": {
"react@18.2.0": "node_modules/.pnpm/react@18.2.0/node_modules/react/LICENSE"
}
}

Exclude​

The exclude option allows you to exclude a dependency from the generated output file. This is useful if a dependency accidentally lists one of it's own dev-dependencies as a normal dependency and you want to exclude that dev-dependency.

{
"exclude": ["lodash@1.2.3"]
}

File Location​

If you want to keep your config file in a different location to the current working directory (or a ./.config directory) then you can specify the location of the config file using the --config CLI flag.

generate-license-file --config ./path/to/config.json