npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-file-checksum

v2.0.2

Published

A gulp plugin for generating checksum file.

Downloads

1,870

Readme

gulp-file-checksum Github workflow Coverage Status

Installation

Install pakcage with NPM and add it to your development dependencies

npm install --save-dev gulp-file-checksum

Usage

Generate a checksum file

The following generages a file dist/package_checksum.txt in the format defined by the template.

const fileChecksum = require('gulp-file-checksum');
const template = `
MD5     : {md5}
SHA1    : {sha1}
CRC32   : {crc32}
size    : {size} Bytes
Datetime: {dateime}
`
gulp.task('checksum',() => {
    return gulp.src('dist/package.zip', {
        buffer: false // for large files
    })
    .pipe(fileChecksum({
        template: template,
        output: '{filename}_checksum.txt'
    }))
    .pipe(gulp.dest('dist'))
})

The contents of the checksum file will look like this:

MD5     : 2f90ce3426541817e0dfd01cae086b60
SHA1    : d817d144dd1397efc52b9ce1dfc9e5713e7265e6
CRC32   : dfc51702
size    : 7051797 Bytes
Datetime: 2018-07-28 21:48:34

Options

  • template - string

    A template allow users to customize the output format and use placeholder syntax({}) to define the output content at the specified location. The built-in placeholders are as follow:

    1. md5,sha1,sha256,sha512 etc. - All hash algorithms are provided by crypto

    2. crc1,crc8,crc24,crc32 etc. - All crc algorithms are provided by crc

    3. size - File size in bytes

    4. datetime - {datetime:YYYY-MM-DD HH:mm:ss A}, The time format please refer to the documentation of momentjs

    5. run - Run unix shell commands defined in shellCommand option via shelljs and get the results:

      fileChecksum({
          template: `{run:git-revision}`,
          shellCommands: {
              'git-revision': `
                  git rev-parse --short HEAD
              `
          }
      })
  • prefix & suffix - string [optional]

    Defines the prefix and suffix of the placeholder in your template. Default: { and }

  • output - string

    The name of output file. Support these placeholders: {basename}, {extname}, {filename};

  • plugins - class

    Sometimes you need to add a custom placeholder in your template, this option allows you to do that like the following example:

    // {time:yyyy-MM-dd}
    class FormatedTimePlugin {
        static get names() {
            return ['time'];
        }
        constructor(file, gulpOptions, placeholder) {
            const firstColonIndex = placeholder.indexOf(':');
            if(firstColonIndex > -1) {
                this.format = placeholder.substring(firstColonIndex);
            } else {
                this.format = "YYYY-MM-DDTHH:mm:ss.SSS"; // default format
            }
        }
        preprocess (template) {
            //
        }
        receiveChunk (chunk) {
            // ignore
        }
        finish(){
            return {
                time: someTimeLibray(new Date(), this.format);
            };
        }
    }
    // gulpfile.js
    fileChecksum({
        template: `
        Date: {time:YYYY-MM-DD}
        `.trim(),
        plugins: [FormatedTimePlugin]
    })