license-header-checker

module
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2023 License: MIT

README

Header

license-header-checker

Test Status

Multiplatform command line tool that checks whether the license headers are included in the source files of a project.

  • It can insert the license to a file in case it does not exist (optional).
  • It can replace the license of a file in case it is different from the target (optional).
  • Only the selected file extensions will be processed.
  • Specific folders, files and paths can be ignored.

DISCLAIMER

The tool looks for the keywords license or copyright inside the first block comment of the file to determine whether the file contains a valid license.

By default, it is configured for the /* ... */ format but a custom regular expression can be provided for other types using the -e option.

Go build tags (or anything that is not a block comment that could be before the license) are respected when replacing the license.

Command Usage

Syntax
license-header-checker [-a] [-r] [-v] [-i path1,...] license-header-path src-path extensions...
Options
  -a        Add the target license in case the file does not have any.
  -r        Replace the existing license by the target one in case they are different.
  -v        Be verbose during execution.
  -i        A comma separated list of the folders, files and/or paths that should be ignored.
            It does not support wildcards.
  -e        Custom regular expression to support other comment types. If not supplied, the default one will be used (for /* ... */ style comments)
  -version  Display version number.
Example
license-header-checker -v -a -r -i node_modules,client/assets ../license_header.txt . js ts

Usage in CI

GitHub Action example
name: License Check
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v3
      - name: Install license-header-checker
        run: curl -s https://raw.githubusercontent.com/lluissm/license-header-checker/master/install.sh | bash
      - name: Run license check
        run: ./bin/license-header-checker -a -r -i testdata ./license_header.txt . go && [[ -z `git status -s` ]]

How to install

Install script

On Linux, macOS or a terminal like Git Bash in Windows, the installation script can be used for convenience.

To install the latest version:

curl -s https://raw.githubusercontent.com/lluissm/license-header-checker/master/install.sh | bash

To install a specific version (e.g., v.1.3.0):

curl -s https://raw.githubusercontent.com/lluissm/license-header-checker/master/install.sh | bash -s v1.3.0
Binary packages

The binary packages for Linux, Windows and macOS are uploaded for each release and can be downloaded from the releases page.

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL