Add or update copyright headers on source code files by scanning directory patterns recursively.
Installation
Global:
npm i @quintype/copyright-header -g
As local devDependency:
npm i @quintype/copyright-header --save-dev
Usage Examples
List of supported file extensions supported:
copyright-header -ex
Add or update copyright headers:
copyright-header -i "test/files/**/*" -f test/header.js
Options
Usage: copyright-header [options]
Options:
-f, --license-file <file> copyright license file
-i, --include-path <paths> recursively insert header in all files found in path (allows multiple file patterns separated by space and within double quotes '"')
-e, --exclude-path <paths> skip adding headers for files in the path (allows multiple file patterns separated by comma space and within double quotes '"')
-u, --include-git-untracked include git untracked files, by default git untracked files will be skipped
-s, --stage-files add file changes to git staging
-ex, --supported-file-extensions list supported file extensions
-V, --version output the version number
-h, --help display help for command
Copyright license file
- Copyright license information in this file will be added as header to the source code files.
- It should be a javascript file (.js) and can have dynamic content using template string.
- Example license file,
// ************************************************************************
// * © [2015 - ${new Date().getFullYear()}] Quintype Technologies India Private Limited
// * All Rights Reserved.
// *************************************************************************
- Program will read the license info as-is including empty lines after the comment, modify comment syntax based on the target file and append it to the target file beginning.
- Make sure to check exact number of new lines added after the comment using text editors like vim. If using visual editors like vscode, then add an additional new line to the number of ones intended.
Add support for new language/file extensions
- Add an entry in the file
copyright-header/src/config/index.ts
under SUPPORTED_LANGUAGES
, similar to the one below
{
name: 'Ruby',
fileExtensions: ['rb'],
commentSyntax: {
singleLine: {
start: ['#']
}
}
}