gulp-header-comment

Gulp plugin to add header comments to files

MIT 11 个版本
安装
npm install gulp-header-comment
yarn add gulp-header-comment
pnpm add gulp-header-comment
bun add gulp-header-comment
README

gulp-header-comment

Greenkeeper badge Build Status Npm version

gulp-header-comment is a Gulp extension to add comments to file(s) in the pipeline.

Install

npm install --save-dev gulp-header-comment

Usage

const headerComment = require('gulp-header-comment');

gulp.src('**/*.js')
  .pipe(headerComment('License MIT'))
  .pipe(gulp.dest('./dist/'))

The generated comment will use:

  • Block comment for JS, LESS, CSS and SASS files (i.e starts with /** and ends with */).
  • HTML comments for HTML files (i.e starts with <!-- and ends with -->).
  • Hash comments for appcache and hidden files (i.e starts with #).
  • The default is the block comment otherwise.

See https://github.com/3rd-Eden/commenting, as this package is used to generate comments according to file extensions.

Templating

Header strings can use lodash, moment and data from package.json:

const headerComment = require('gulp-header-comment');

gulp.src('**/*.js')
  .pipe(headerComment(`
    License: <%= pkg.license %>
    Generated on <%= moment().format('YYYY') %>
    Author: <%= _.capitalize(pkg.author) %>
  `))
  .pipe(gulp.dest('./dist/'))

You can also point to a file on disk:

const headerComment = require('gulp-header-comment');

gulp.src('**/*.js')
  .pipe(headerComment({
    file: path.join(__dirname, 'header.txt'),
    encoding: 'utf-8', // Default is UTF-8
  }))
  .pipe(gulp.dest('./dist/'))

ChangeLogs

See here.

License

MIT License (MIT)

Contributing

If you find a bug or think about enhancement, feel free to contribute and submit an issue or a pull request.

版本列表
0.10.0 2021-11-15
0.9.0 2020-12-28
0.8.0 2020-05-17
0.7.0 2020-05-03
0.6.1 2019-06-04
0.5.0 2019-05-31
0.4.0 2018-03-06
0.3.0 2017-12-25
0.2.1 2017-07-03
0.2.0 2017-05-11
0.1.0 2017-02-23