headnote
Version:
Prepend banner headers to files.
123 lines (88 loc) • 3.46 kB
Markdown
# headnote
[](https://www.lujiahao.com/sponsor)
[](https://www.npmjs.com/package/headnote)
[](http://www.typescriptlang.org/)
[](https://www.jsdelivr.com/package/npm/headnote)
[](https://codecov.io/gh/ajiho/headnote)
[](https://github.com/ajiho/headnote/actions/workflows/test.yml)
[](https://nodejs.org/en/about/previous-releases)
[](https://vitest.dev/)
[](https://bundlejs.com/?q=headnote)
[](https://opensource.org/licenses/MIT)
---
English | [简体中文](./README.md)
## What is headnote?
A command-line tool that quickly generates file banners based on package.json or custom configurations.
## Quick Start
**Install using npm**
```bash
$ npm install -D headnote
```
**Install using Yarn**
```bash
$ yarn add -D headnote
```
## Usage
> [!NOTE]
> Paths support Glob patterns.
```bash
$ headnote dist/**/*.css
```
headnote can read configurations from `.json`, `.js`, `.ts`, `.mjs`, `.mts` files, or from the `headnote` key in your `package.json` file.
- To use a custom configuration file, specify it via the command line:
```bash
$ headnote dist/**/*.css --config headnote.config.mjs
```
Example `headnote.config.mjs` configuration:
```js
export default {
banner: `/*
* Awesome Project v1.0.0
* Copyright 2023-2025 yourname
* license MIT
*/`,
}
```
- If the `--config` flag is omitted, headnote will look for configuration under the `headnote` key in your `package.json`. If this key is not found, headnote will by default read data from `package.json` to generate the banner comment.
Example `package.json` configuration:
```json
{
"name": "headnote",
"version": "1.0.0",
"homepage": "https://lujiahao.com",
"license": "MIT",
"author": "ajiho <lujiahao@88.com>"
}
```
This will generate the following banner comment:
```js
/*!
* Headnote v1.0.0
* https://lujiahao.com
*
* Copyright (c) 2025 ajiho <lujiahao@88.com>
* Licensed under the MIT license
*/
```
## CLI
Run `npx headnote --help` for help information.
```bash
Usage: headnote [options] <files...>
Prepend banner headers to files.
Arguments:
files Files or glob patterns
Options:
-V, --version output the version number
-c, --config <path> Path to config file
--exclude <patterns...> Exclude files or directories (supports glob)
--dry-run Print actions without writing files
-h, --help display help for command
Examples:
# Prepend banner to all JS files in src/
$ headnote "src/**/*.js"
# Load custom config file
$ headnote "src/**/*.js" --config headnote.config.mjs
```
## License
[MIT](https://github.com/ajiho/headnote/blob/main/LICENSE)
Copyright (c) 2025-present, ajiho