# @fomantic/gulp-header 中文文档

规范地址：https://npmcn.com/package/%40fomantic/gulp-header/

版本：2\.2\.0
npm 元数据更新时间：2026-07-18T09:29:31.314Z
中文译文更新时间：2026-11-15T04:11:35.618Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40fomantic/gulp-header
原文对照：https://npmcn.com/package/%40fomantic/gulp-header/?lang=original
项目主页：https://github.com/fomantic/gulp-header#readme
源码仓库：https://github.com/fomantic/gulp-header

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：9.7 kB，5 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：3 个
- 首次发布：2024-05-07T16:51:36.687Z
- 最新版本发布：2026-07-18T09:29:31.134Z
- 近 30 天下载量：22666（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：2（近 12 个月 1 个）

## 中文简介

Gulp 扩展以添加标题到管道中的文件 .

## 安装

```sh
npm install @fomantic/gulp-header
```

也可以使用：`pnpm add @fomantic/gulp-header`、`yarn add @fomantic/gulp-header`、`bun add @fomantic/gulp-header`

## README

这个项目的峡谷位置是现在 [木浆社区/木浆头](https://github.com/gulp-community/gulp-header)。 。 。 .

# 纸浆头

> ### 使用更新的依赖关系伪造版本
> 
> 原始重播时间 [https://github.com/gulp-community/gulp-header 页面存档备份,存于互联网档案馆](https://github.com/gulp-community/gulp-header)
> 
> 这个版本用一个更简单的,仍然有效的替换来取代lodash模板. 所有测试仍然通过

[![npm version](https://img.shields.io/github/package-json/v/gulp-community/gulp-header)](https://www.npmjs.com/package/gulp-header) [![Actions Status](https://github.com/gulp-community/gulp-header/workflows/Tests/badge.svg)](https://github.com/gulp-community/gulp-header/actions) [![Code Coverage](https://img.shields.io/coveralls/github/gulp-community/gulp-header)](https://github.com/gulp-community/gulp-header) [![Dependency Status](https://img.shields.io/librariesio/release/npm/gulp-header)](https://libraries.io/npm/gulp-header) ![Github Issues](https://img.shields.io/github/issues/gulp-community/gulp-header?style=plastic) [![MIT License](https://img.shields.io/github/license/gulp-community/gulp-header)](https://npmcn.com/package/%40fomantic/gulp-header/LICENSE)

ulp头是 [古尔普](https://github.com/gulpjs/gulp) 扩展以在管道中的文件中添加一个标题. [Gulp 是一个流畅的构建系统](https://github.com/gulpjs/gulp) 使用 [节点.js](http://nodejs.org/)。 。 。 .

## 安装

```javascript
npm install --save-dev gulp-header
```

## 使用量

```javascript
// assign the module to a local variable
var header = require('gulp-header');


// literal string
// NOTE: a line separator will not be added automatically
gulp.src('./foo/*.js')
  .pipe(header('Hello'))
  .pipe(gulp.dest('./dist/'))


// ejs style templating
gulp.src('./foo/*.js')
  .pipe(header('Hello <%= name %>\n', { name : 'World'} ))
  .pipe(gulp.dest('./dist/'))


// ES6-style template string
gulp.src('./foo/*.js')
  .pipe(header('Hello ${name}\n', { name : 'World'} ))
  .pipe(gulp.dest('./dist/'))


// using data from package.json
var pkg = require('./package.json');
var banner = ['/**',
  ' * <%= pkg.name %> - <%= pkg.description %>',
  ' * @version v<%= pkg.version %>',
  ' * @link <%= pkg.homepage %>',
  ' * @license <%= pkg.license %>',
  ' */',
  ''].join('\n');

gulp.src('./foo/*.js')
  .pipe(header(banner, { pkg : pkg } ))
  .pipe(gulp.dest('./dist/'))


// reading the header file from disk
var fs = require('fs');
gulp.src('./foo/*.js')
  .pipe(header(fs.readFileSync('header.txt', 'utf8'), { pkg : pkg } ))
  .pipe(gulp.dest('./dist/'))


// for use with coffee-script
return gulp.src([
        'src/*.coffee',
    ])
    .pipe(header(banner, { pkg : pkg } ))
    .pipe(sourcemaps.init()) // init sourcemaps *after* header
    .pipe(coffee({
        bare: true
    }))
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('dist/js'))
```

## 问题和警报

我的手柄在推特上是 [@ tracker1 (英语)](https://twitter.com/tracker1) - 如果有急事,我会收到推特通知.

## API 密码

### 页眉( 文本, 数据)

#### 文本

类型 : `String` 默认 : `''`

模板文本.

#### 数据

类型 : `Object` 默认 : `{}`

用于填充文本的数据对象 .

除了通过的数据, `file` 将会是 [流对象](https://github.com/gulpjs/vinyl#instance-properties) 用于模板化文件 `filename` 将会是河道的相对位置.

_注:使用 `false` 将禁用信头的模板处理_

## 常见问题

### @fomantic/gulp-header 是什么？

Gulp 扩展以添加标题到管道中的文件 \.

### 如何安装 @fomantic/gulp-header？

在项目目录运行 npm install @fomantic/gulp-header，或使用 pnpm add / yarn add / bun add。

### @fomantic/gulp-header 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/fomantic\_\_gulp-header 是否存在。

### @fomantic/gulp-header 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @fomantic/gulp-header 可以商用吗？

@fomantic/gulp-header 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @fomantic/gulp-header 的下载量有多少？

根据 npm 官方下载统计，@fomantic/gulp-header 在 2026/10/15 – 2026/11/13 这 30 天内被下载 22,666 次，日均约 756 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @fomantic/gulp-header 还在维护吗？

最新版本 2\.2\.0 发布于 2026/07/18（3 个月前）；至今共发布 2 个版本，其中过去 12 个月发布了 1 个；首次发布于 2024/05/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

