English | 简体中文
一个命令行工具,可以从 package.json 或自定义配置,快速生成文件横幅。
使用 npm 安装
$ npm install -D headnote使用 Yarn 安装
$ yarn add -D headnoteNote
路径支持 Glob 模式
$ headnote dist/**/*.cssheadnote 可以从 .json、.js、.ts、.mjs、.mts、 文件或你的 package.json 文件中读取配置。
- 若要使用自定义配置文件,请在命令行中指定它:
$ headnote dist/**/*.css --config headnote.config.mjsheadnote.config.mjs 配置示例:
export default {
banner: `/*
* Awesome Project v1.0.0
* Copyright 2023-2025 yourname
* license MIT
*/`,
}- 如果省略
--config标志,headnote 会在你的package.json中查找headnote键的配置。如果没有找到该键,headnote默认从package.json读取数据生成横幅注释。
package.json 配置示例:
{
"name": "headnote",
"version": "1.0.0",
"homepage": "https://lujiahao.com",
"license": "MIT",
"author": "ajiho <lujiahao@88.com>"
}会生成如下横幅注释:
/*!
* Headnote v1.0.0
* https://lujiahao.com
*
* Copyright (c) 2025 ajiho <lujiahao@88.com>
* Licensed under the MIT license
*/通过运行npx headnote --help获取帮助信息
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.mjsCopyright (c) 2025-present, ajiho