npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

quick-license

v1.0.1

Published

A tool to apply, remove, and check licenses in .js and .css files.

Downloads

4

Readme

Quick License

quick-license is a Node.js package that allows you to easily apply, check, and remove license headers from your JavaScript, CSS, and other specified files.

Features

  • Apply license headers to specified files.
  • Check which files have the license header applied.
  • Remove license headers from files.
  • Configurable inclusion and exclusion patterns.
  • Supports custom file extensions.

Installation

Install the package globally using npm:

npm install -g quick-license

Usage

Command Line Interface

You can use quick-license through the command line with the following commands:

  • quick-license test: Lists the files that will be affected based on your configuration.
  • quick-license license: Applies the license header to the specified files.
  • quick-license unlicense: Removes the license header from the specified files.
  • quick-license check: Checks the license status of the specified files.
  • quick-license check -f <file>: Checks the license status of a specific file or files (comma-separated).

Example usage:

quick-license test
quick-license license
quick-license unLicense
quick-license check
quick-license check -f path/to/file.js
quick-license check --file path/to/file1.js,path/to/file2.css

Configuration

The configuration for quick-license can be specified in your package.json file under the licenseScope key, or in a separate quickLicense.json file in the root directory. If neither is found, a default configuration is used.

Example package.json configuration:

{
  "licenseScope": {
    "include": ["www/**/*"],
    "exclude": ["www/**/test.js", "node_modules/"],
    "allowedExtensions": ["js", "css", "mjs", "ts"],
    "licenseFile": "license.txt"
  }
}

Example quickLicense.json configuration:

{
  "licenseScope": {
    "include": ["www/**/*"],
    "exclude": ["www/**/test.js", "node_modules/"],
    "allowedExtensions": ["js", "css", "mjs", "ts"],
    "licenseFile": "license.txt"
  }
}

License File

Create a license.txt file in your project root that contains the license text you want to apply. This text will be added between the predefined license start and end markers.

Example license.txt:

Your License Text Here

Programmatic Usage

You can also use quick-license programmatically in your Node.js scripts:


const QuickLicense = require('quick-license');

async function main() {
  const config = await QuickLicense.loadConfig();
  const quickLicense = new QuickLicense(config);

  await quickLicense.test();
  await quickLicense.license();
  await quickLicense.unLicense();
  await quickLicense.check();
  await quickLicense.check('path/to/file.js');
}

main().catch(err => console.error(err));` 

Methods

test()

Traverse and output the list of files that will be affected based on the configuration.

license()

Applies the license header to the specified files.

unLicense()

Removes the license header from the specified files.

check(filepath)

Checks the license status of the specified files. If filepath is given, it returns the status of that file(s). If no parameter is given, it returns the status of all files.

isLicensed(file)

Checks if the license is applied to the given file.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.