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 🙏

© 2025 – Pkg Stats / Ryan Hefner

auto-license

v1.0.7

Published

Automatically add license headers to new files

Readme

auto-license

Automatically add license headers to new files in a specified folder.

Description

Auto-License is a Node.js CLI tool that monitors a specified folder for new files and automatically prepends a user-defined license header to them. It uses chokidar for file watching and readline-sync for interactive user input.

The tool safely ignores hidden folders (like .git), node_modules, and build directories, and only applies license headers to supported source code file extensions (e.g., .js, .ts, .py, .java, etc.).

Installation

You can install Auto-License globally via npm to use it as a command-line tool:

npm install -g auto-license

Alternatively, install it locally in your project:

npm install auto-license

Usage

  1. Run the tool using the command:

    • For global installation:

      auto-license
    • For local installation:

      npx auto-license
    • Alternatively, if installed locally, you can add a script to your package.json:

      "scripts": {
        "license": "auto-license"
      }

      Then run it with:

      npm run license
  2. Enter the folder path you want to monitor for new files when prompted. The path will be resolved relative to your current working directory.

  3. Input your license text. Type each line of the license, and when finished, type END on a new line to complete the input. The license text will be formatted as a multi-line comment block (/* ... */).

  4. The tool will:

    • Automatically create the folder if it doesn’t exist.
    • Start watching for new source files.
    • Prepend the license header if the file doesn’t already begin with a comment block.

Example

$ auto-license
Enter folder path to watch: ./src
Enter your license text (end with a single line with only "END"):
MIT License
Copyright (c) 2025 Your Name
END
Watching folder: /path/to/src ...

If a new file example.js is created in the ./src folder, the tool will add the license header:

/*
MIT License
Copyright (c) 2025 Your Name
*/

[original file content]

Features

  • Interactive CLI: Prompts for folder path and license text.
  • Automatic License Addition: Adds license headers to new files in the watched folder.
  • Safe Folder Monitoring: Skips .git, node_modules, dist, and other hidden/system folders.
  • Extension Filtering: Only modifies supported source file types (e.g., .js, .ts, .py, .java, .c, .cpp, .cs, .go, .rb, .php, .swift, .rs, .bal).
  • Folder Creation: Automatically creates the specified folder if it doesn't exist.
  • Skips Existing Licenses: Avoids adding a license header if the file already starts with a comment block.

Requirements

  • Node.js (version 12 or higher recommended)
  • npm (comes with Node.js)

Dependencies

  • chokidar: ^3.6.0 — For watching file system changes.
  • readline-sync: ^1.4.10 — For synchronous user input in the CLI.

Author

Uditha Vithanage

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue on the GitHub repository.

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.