• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

remko/gulp-hashsum: Gulp plugin to generate checksum files

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

remko/gulp-hashsum

开源软件地址(OpenSource Url):

https://github.com/remko/gulp-hashsum

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

gulp-hashsum: Generate checksum files with Gulp

A Gulp plugin for generating a checksum file with the hash checksums of the passed files. The file follows the same format as shasum, sha1sum, md5sum, and similar tools.

Since it only writes the file when the checksums have changed, can also be used as a timestamp.

Installation

npm install gulp-hashsum --save-dev

Usage

Generate a hash file

The following generates a file app/SHA1SUMS with all the SHA-1 checksums of all the .js files in the app directory.

var hashsum = require("gulp-hashsum");

gulp.src(["app/**/*.js"]).
    pipe(hashsum({dest: "app"}));

The contents of the SHA1SUMS file will look like this:

3ff1f9baca7bf41fe4a12222436025c036ba88bf  main.js
14de86e007f14bc0c6bc9a84d21cb9da908495ae  submodule/sub.js

Use a different hash than SHA-1

The following generates a file app/MD5SUMS with all the MD5 checksums of all the .js files in the app directory.

var hashsum = require("gulp-hashsum");

gulp.src(["app/**/*.js"]).
    pipe(hashsum({dest: "app", hash: "md5"}));

Use it as a timestamp

Since gulp-hashsum only writes the hash file whenever its content changes, you can use it as a checksum file, e.g. to restart Passenger Phusion whenever a file changes, by specifying restart.txt as the filename:

var hashsum = require("gulp-hashsum");

gulp.src(["app/**/*.js"]).
    pipe(hashsum({filename: "tmp/restart.txt"}));

Stream

Instead of writing the checksum file to disk, you can stream it and pass it to pipes:

var hashsum = require("gulp-hashsum");

gulp.src(["app/**/*.js"]).
    pipe(hashsum({stream: true})).
    pipe(gulp.dest("app"));

API

hashsum(options)

  • options.dest - string
    The destination directory of the hash file.
    All paths in the hash file will be relative to this directory.

    Default: process.cwd() (the current working directory)

  • options.filename - string
    The filename of the hash file.
    Default: <HASH-NAME>SUMS (i.e. SHA1SUMS when sha1 is used as hash function)

  • options.hash - string
    The hash function to use. Must be one supported by crypto.
    Default: sha1

  • options.force - boolean
    Always overwrite the hashsum file, regardless of whether the contents changed.
    Default: false

  • options.delimiter - string
    Separator between hashsum and filename. Default: `` (two spaces)

  • options.json - boolean
    Format hash file as a JSON object (instead of a options.delimiter-delimited file). E.g.:

      {
        "dir1/file1": "3ff1f9baca7bf41fe4a12222436025c036ba88bf",
        "dir1/file2": "14de86e007f14bc0c6bc9a84d21cb9da908495ae"
      }
    

    Default: false

  • options.stream - boolean
    Instead of writing the file to disk, stream it (so it can be passed to later pipes)

    Default: false

Changelog

1.2.0 (2018-04-16)

  • Add stream option.

1.1.0 (2016-06-16)

  • Add json option.

1.0.1 (2016-01-29)

  • Remove buffertools dependency

1.0.0 (2014-09-29)

  • Initial release



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
akella/gulp4发布时间:2022-06-21
下一篇:
imlucas/gulp-juice: process html files through juice to inline CSS发布时间:2022-06-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap