From 4aef2e998a212e8a1fd8b9934d836f474eb117ba Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Mon, 14 Sep 2015 18:47:46 +0300 Subject: [PATCH 1/4] Updated dependencies --- package.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a33eb2d..bdb0472 100644 --- a/package.json +++ b/package.json @@ -29,13 +29,14 @@ "test": "grunt test" }, "devDependencies": { + "grunt": "0.4.0", + "grunt-contrib-clean": "0.4.0rc6", "grunt-contrib-copy": "0.4.0", "grunt-contrib-jshint": "0.1.1rc6", - "grunt-contrib-clean": "0.4.0rc6", - "grunt-contrib-nodeunit": "0.1.2rc6", - "grunt": "0.4.0rc6" + "grunt-contrib-nodeunit": "^0.4.1", + "nodeunit": "^0.9.1" }, "keywords": [ "gruntplugin" ] -} \ No newline at end of file +} From c31b0666cbd14a698a7bbca663644cd492809244 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Mon, 14 Sep 2015 18:48:33 +0300 Subject: [PATCH 2/4] Fixed utf8 decoding of binary files --- Gruntfile.js | 8 +++++++- tasks/rev.js | 3 ++- test/fixtures/binary.bin | Bin 0 -> 1024 bytes test/rev_test.js | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/binary.bin diff --git a/Gruntfile.js b/Gruntfile.js index a9e2b22..6dfbf90 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -33,7 +33,7 @@ module.exports = function(grunt) { test: { flatten: true, expand: true, - src: ['test/fixtures/*.txt'], + src: ['test/fixtures/*.{txt,bin}'], dest: 'tmp/', }, }, @@ -56,6 +56,12 @@ module.exports = function(grunt) { }, src: ['tmp/international.txt'] }, + binary_options: { + options: { + encoding: 'binary' + }, + src: ['tmp/binary.bin'] + } }, // Unit tests. diff --git a/tasks/rev.js b/tasks/rev.js index f6f77c2..f9959cf 100644 --- a/tasks/rev.js +++ b/tasks/rev.js @@ -17,7 +17,8 @@ module.exports = function(grunt) { function md5(filepath, algorithm, encoding, fileEncoding) { var hash = crypto.createHash(algorithm); grunt.log.verbose.write('Hashing ' + filepath + '...'); - hash.update(grunt.file.read(filepath), fileEncoding); + //set encoding to null because in other case grunt.file.read use utf8 by default + hash.update(grunt.file.read(filepath, {encoding: null}), fileEncoding); return hash.digest(encoding); } diff --git a/test/fixtures/binary.bin b/test/fixtures/binary.bin new file mode 100644 index 0000000000000000000000000000000000000000..0ee99d259a0030d683a7230bce318ae4a1b08026 GIT binary patch literal 1024 zcmV+b1poUwaJrAlAaTV4FmpoAeGZJbVDa)>Lv-v1U@3?v|0}TAF^3p;`mB~6ixQ1? zY}}(=-u>}{+65Q^ew(

CPy!*xx6Qw-s0_sB(kMofb20w0{`m-FF)JE!)XYf1cWO zdv!>2cCE)!Y^)_CKE9Sv;s9VoE#~fo>a6s!8GzmCs&i1XGsF{y`k=Tv=0{_rM19M; z)Jr-ZfW&|W9N=3y;oXMC2Mz>=w15Iy2sr&{55H!~y!{`QfzG zIT{N?EGUl=8kPJG#!FwONxA?fE7gTkK8n+e<^WVeicLQb@!*h0Fsf_K-48HQ z^HEUb``#`@=%zou4z_txDFlMf<6hyx0#6Sk3V$6_1@PU==lP1b-v1o0SM>^Ng9&dP z(i~~y13(GK0?DdCEACx#7x(w{Q|mqXf6mTBmE2YCR<_nl)&?fFC4QJ!`>FRv325}T zK^W_4HKShDPM^O!jvNbN4^VlaQhHppGtFr?gH>=T&u|GJS-AQF0xanK-{)lTf72PU zU^F8io0`F;+N;&@vOKg&%OGf|i#MMqnFFJPzO zjVF-|yU?N-M?7g#TF8;$1OO07SXXElt#K6V)^V}>ti0Vz&Syt%hR5xdx{gcy$c}mN zCUiDj92+CzmwgAeX#B2oF0p!idcr9xpW|f!2*~rDh&w*VvgszPjlhehG}mz*y*Rs* zYH9xFx2O*BZ;h(J!ZScRbRbH$avn#7g$8<#q-Hp+TH%s71yR@(DYn(j4Dh0w1k@R| z|KIT@SDr4IMr*FyMFeiK**4!M6k*_IN7k4%TCN42sv5^YJI|3>R?(ypY literal 0 HcmV?d00001 diff --git a/test/rev_test.js b/test/rev_test.js index b876642..97ce49a 100644 --- a/test/rev_test.js +++ b/test/rev_test.js @@ -50,5 +50,12 @@ exports.rev = { test.ok(exists, '8 character MD5 hash prefix for international content'); test.done(); + }, + binary_options: function(test) { + test.expect(1); + var exists = grunt.file.exists('tmp/2ac69376.binary.bin'); + test.ok(exists, '8 character MD5 hash prefix for binary content'); + + test.done(); } }; From 11f66df23e4f1adcee4f13896953edf1d919e42e Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Mon, 14 Sep 2015 18:50:39 +0300 Subject: [PATCH 3/4] improved encoding option docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95972c1..cdc72f5 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ grunt.initConfig({ Type: `String` Default value: `'utf8'` -The encoding of the file contents. +The encoding of the file contents. Possible values `'utf8'`, `'ascii'` or `'binary'`. #### options.algorithm Type: `String` From 31a99f1e71b74c970baeb591364269a84c0ef3aa Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Mon, 14 Sep 2015 18:51:28 +0300 Subject: [PATCH 4/4] Bump version to 0.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bdb0472..9d72238 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-rev", "description": "Static file asset revisioning through content hashing", - "version": "0.1.0", + "version": "0.1.1", "homepage": "https://github.com/cbas/grunt-rev", "author": { "name": "Sebastiaan Deckers",