Adds license headers to your source files
Automates the prepending of a license header doc block to your directory(ies) of source files.
Currently still in development, but will:
- Accept a directory of source files to process (no support for single files yet)
- Accept a file path containing your custom license doc block
- Will not add license headers to files that have comments before the class declaration (class doc blocks are okay)
./bin/licenser run /path/to/source/files /path/to/license/fileto process source files
Licenser supports the following built-in licenses:
- The Apache 2.0 license (referred to as
- The MIT license (referred to as
To use one of these built-in licenses you just replace the path to your custom licenses file with the name of the built-in license instead. For example if you wanted to use the MIT license then you would run something like:
./bin/licenser run /path/to/your/source/files mit
When using a built-in license the Licenser will replace special placeholders with custom values. The following twig placeholder values are used:
thisYear(always replaced with the current year)
owner(replaced with the value you specify via the
--ownersoption, or ignored if you don't specify a value)
You can tell the Licenser to replace an existing license header with a new one by just using the
when running the command. This will tell Licenser to remove any existing licenses and replace them with the new one generated.
It is recommended that you have your source files under version control when running the tool as it is still experimental and very much in development.
Add support for replacing an existing license(thanks to @markwilson) Add built-in license options
- Add dry-run option to see affected files before adding headers
- Add support for processing single files
- Add support for placeholders in custom license files (such as year, owner etc.)
If you find any problems with the library then open an issue with a description of the problem and I will aim to resolve it.