New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-digest

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-digest - npm Package Compare versions

Comparing version 0.1.2 to 1.0.0

2

package.json
{
"name": "grunt-digest",
"description": "Create digested copies of assets and add mapping to a manifest. Useful with rails applications",
"version": "0.1.2",
"version": "1.0.0",
"homepage": "https://github.com/zendesk/grunt-digest",

@@ -6,0 +6,0 @@ "author": {

@@ -6,3 +6,3 @@ # grunt-digest

## Getting Started
This plugin requires Grunt `~0.4.1`
This plugin requires Grunt `~0.4.1` and has been tested with Rails 4.

@@ -9,0 +9,0 @@ If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

@@ -11,2 +11,4 @@ /*

var fs = require("fs");
module.exports = function(grunt) {

@@ -20,3 +22,3 @@

path = require('path'),
filemap = {},
filemap = { files: {}, assets: {} },
tally = 0,

@@ -29,7 +31,8 @@ options;

separator: '-',
algorithm: 'md5'
algorithm: 'md5',
basePath: false
});
this.filesSrc.forEach(function(filepath) {
var data, file, ext, base, digest, fileDigest, filepathDigest;
var data, file, ext, base, digest, stats, fileDigest, filepathDigest, fileWithPath;

@@ -40,6 +43,14 @@ file = path.basename(filepath);

if(options.basePath) {
fileWithPath = path.relative(options.basePath, filepath);
base = fileWithPath.substr(0, fileWithPath.lastIndexOf('.'));
} else {
fileWithPath = file;
}
data = grunt.file.read(filepath);
stats = fs.statSync(filepath);
digest = crypto.createHash(options.algorithm).update(data).digest('hex');
fileDigest = [base, options.separator, digest, ext].join('');
filepathDigest = filepath.replace(file, fileDigest);
filepathDigest = filepath.replace([base, ext].join(''), fileDigest);

@@ -50,3 +61,9 @@ //Copy file

//Add file to map
filemap[file] = fileDigest;
filemap.files[fileDigest] = {
digest: digest,
mtime: new Date(stats.mtime).toISOString(),
size: stats.size,
logical_path: file
};
filemap.assets[fileWithPath] = fileDigest;
grunt.verbose.writeln(file.cyan + ' -> ' + fileDigest.cyan);

@@ -53,0 +70,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc