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-md5-thing

v0.0.8

Published

Insert MD5 hash into a filenames and update a dictionary of information about the hashes and renamed files

Downloads

3

Readme

gulp-md5-thing

Insert an MD5 hash into afilenames and retrieve information about the generated hash and hashed filename

npm install --save-dev gulp-md5-thing

Usage

var md5Dict = {};

var gulp_md5_thing = require("gulp-md5-thing");

gulp.src("./src/*.ext")
		.pipe(gulp_md5_thing( arg ))
		.pipe(gulp.dest("./dist"));

API

gulp_md5_thing( arg )

arg

	Type: `String` or `Object` 
	Optional: 
	If type == `String`:
			'arg'  is a number representing the number of characters from the md5 hash string to be used in the filename

	If type == `Object`:
			'arg' may have any or all of the following properties : 
					'size'		  : A number representing the number of characters from the md5 hash string to be used in the filename
					'separator' : A custom separator between the filename and the md5 hash ( e.g. '', '_', '---' )
					'inject'		: A string 'search and replace' token. 
													If provided, and if the token string is present in the file it will be replaced with the md5 hash, 
													calulated on the file's contents before the hash is injected.
					'md5info'   : A reference to a dictionary which will be populated with an entry for each filename processed during execution.
											  		Each entry will contain the following properties after execution:
											   				'hash'				   : The md5 hash created (truncated if 'size' was specified)
											   		 		'hashedfilename' : The new filename with md5 hash inserted
											   		 		'hashedfilepath' : The new filepath with md5 hash inserted

	Default: If arg is omitted a full 32 character md5 hash is used and the separator is '-'

Example

Given the directory structure:

top/
├── src/
		├── file.a.ext
		├── file.b.ext
		├── file.c.ext
		├── file.d.txt
├── dist/
├── ...

and a set of source files, one of which (file.a.ext) contains the replacement token string : '{{MD5_HASH}}'

   var md5_info = {};
   gulp.src('src/**/*.ext', {base: './top'})
				.pipe(gulp_md5_thing({size:6, inject:'{{MD5_HASH}}', separator:'_', md5info:md5_info}))
				.pipe(gulp.dest('./dist'));

will result in:

top/
├── src/
		├── file.a.ext
		├── file.b.ext
		├── file.c.ext
		├── file.d.txt
├── dist/
		├── file.a_6b85e3.ext
		├── file.b_53ef22.ext
		├── file.c_2b86b1.ext
├── ...

and

console.log( md5_info['file.a.ext'].hash );						//  6b85e3
console.log( md5_info['file.a.ext'].hashedfilename );  //  file.a_6b85e3.ext
console.log( md5_info['file.a.ext'].hashedfilepath );  //  src/file.a_6b85e3.ext
. . . 
etc.

and '{{MD5_HASH}}' will be replaced with '6b85e3' in file.a_6b85e3.ext

License

http://en.wikipedia.org/wiki/MIT_License[MIT License]