Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@quintype/copyright-header

Package Overview
Dependencies
Maintainers
27
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@quintype/copyright-header

To manage copyright headers in source files

  • 1.3.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
27
Created
Source

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 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, --git-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 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/update it to the target file beginning.
  • For updating a copyright, existing comment in the file should have any of the following keywords, 'copyright', '(c)', '©'
  • 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 one's intended.

List of supported languages/file extensions

c, cpp, js, jsx, ts, tsx, go, java, clj, py

Adding support for new language/file extensions

  • Currently, this is possible only with a library configuration change. No command line option available to extend language support.
  • Add an entry in the library source code file, copyright-header/src/config/index.ts under SUPPORTED_LANGUAGES, similar to the one below
 {
    name: 'Ruby',
    fileExtensions: ['rb'],
    commentSyntax: {
      singleLine: {
        start: ['#']
      }
    }
  }

Configuring as husky pre commit hook

  • Add the following under scripts in package.json file.

"copyright-header": "copyright-header -f copyright-header-template.js -i \"src/**/*" -s"

  • Above script command will add/update copyright header in copyright-header-template.js file to all source code files under src directory.

  • Add the following in husky pre commit hook config in package.json file,

"husky": {
    "hooks": {
      "pre-commit": "npm run copyright-header"
    }
  }

FAQs

Package last updated on 28 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc