grunt-md5
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -131,2 +131,26 @@ // For testing callbacks. | ||
} | ||
}, | ||
contextAndOptionsAfterEach: { | ||
files: { | ||
'test/fixtures/output/contextAndOptions/': 'test/fixtures/test.js' | ||
}, | ||
options: { | ||
findMe: true, | ||
afterEach: function(fileChange, options) { | ||
var fileContent = 'options=' + typeof options + '\nfindMe=' + options.findMe + '\nthis.nameArgs=' + this.nameArgs; | ||
fs.appendFileSync('test/fixtures/output/contextAndOptions/afterEach.out', fileContent); | ||
} | ||
} | ||
}, | ||
contextAndOptionsAfter: { | ||
files: { | ||
'test/fixtures/output/contextAndOptions/': ['test/fixtures/test.js', 'test/fixtures/test2.js'] | ||
}, | ||
options: { | ||
findMe: true, | ||
after: function(fileChanges, options) { | ||
var fileContent = 'options=' + typeof options + '\nfindMe=' + options.findMe + '\nthis.nameArgs=' + this.nameArgs; | ||
fs.appendFileSync('test/fixtures/output/contextAndOptions/after.out', fileContent); | ||
} | ||
} | ||
} | ||
@@ -133,0 +157,0 @@ }, |
{ | ||
"name": "grunt-md5", | ||
"description": "generate md5 filename", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"homepage": "https://github.com/jney/grunt-md5", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -23,3 +23,3 @@ [![build status](https://secure.travis-ci.org/jney/grunt-md5.png)](http://travis-ci.org/jney/grunt-md5) | ||
files: { | ||
'dest/folder': 'src/file' | ||
'dest/folder/': 'src/file' | ||
}, | ||
@@ -30,3 +30,3 @@ options: { | ||
keepExtension: true, | ||
afterEach: function (fileChange) { | ||
afterEach: function (fileChange, options) { | ||
// Called once for each file processed by the md5 task. | ||
@@ -44,4 +44,13 @@ | ||
// and content is the file content. | ||
// options is the options object of the task | ||
// In this case: | ||
// {encoding: 'utf8', keepBasename: true, keepExtension: true, afterEach: function () {...} after: function () {...}} | ||
// The context (value of "this") is set to the context of the task | ||
// this.nameArgs -> "md5:compile" | ||
// See more information at http://gruntjs.com/api/inside-tasks | ||
}, | ||
after: function (fileChanges) { | ||
after: function (fileChanges, options) { | ||
// Called after all of the files are processed by the md5 task. | ||
@@ -51,2 +60,10 @@ | ||
// [{newPath: '...', oldPath: '...', content: '...'}, ...] | ||
// options is the options object of the task | ||
// In this case: | ||
// {encoding: 'utf8', keepBasename: true, keepExtension: true, afterEach: function () {...} after: function () {...}} | ||
// The context (value of "this") is set to the context of the task | ||
// this.nameArgs -> "md5:compile" | ||
// See more information at http://gruntjs.com/api/inside-tasks | ||
} | ||
@@ -63,6 +80,7 @@ } | ||
## Release History | ||
* 0.1.8 Encoding option, enhancements in directories management (#12, #13, #14) | ||
* 0.1.7 Grunt 0.4.0 ready. `after` parameter. (#9) | ||
* 0.1.9 changing `after` and `afterEach` signature, added `options` argument, plus context | ||
* 0.1.8 Encoding option, enhancements in directories management | ||
* 0.1.7 Grunt 0.4.0 ready. `after` parameter | ||
* 0.1.5 Support for keeping the original file's basename | ||
* 0.1.4 Compatibility with grunt 0.4 (#7, #8) | ||
* 0.1.4 Compatibility with grunt 0.4 | ||
* 0.1.1 Fixing many files handling | ||
@@ -69,0 +87,0 @@ * 0.0.1 First Release |
@@ -26,2 +26,4 @@ /* | ||
}); | ||
var context = this; | ||
@@ -80,3 +82,3 @@ grunt.verbose.writeflags(options, 'Options'); | ||
if (_.isFunction(options.afterEach)) { | ||
options.afterEach(currentFile); | ||
options.afterEach.call(context, currentFile, options); | ||
} | ||
@@ -97,3 +99,3 @@ | ||
if (_.isFunction(options.after)) { | ||
options.after(processedFiles); | ||
options.after.call(context, processedFiles, options); | ||
} | ||
@@ -100,0 +102,0 @@ }); |
@@ -98,3 +98,17 @@ 'use strict'; | ||
test.done(); | ||
}, | ||
contextAndOptionsAfterEach: function(test) { | ||
test.expect(1); | ||
var output = fs.readFileSync('test/fixtures/output/contextAndOptions/afterEach.out', 'utf-8'); | ||
var expected = fs.readFileSync('test/expected/contextAndOptions/afterEach.out', 'utf-8'); | ||
test.equal(output, expected, 'should give options to callback and set task context'); | ||
test.done(); | ||
}, | ||
contextAndOptionsAfter: function(test) { | ||
test.expect(1); | ||
var output = fs.readFileSync('test/fixtures/output/contextAndOptions/after.out', 'utf-8'); | ||
var expected = fs.readFileSync('test/expected/contextAndOptions/after.out', 'utf-8'); | ||
test.equal(output, expected, 'should give options to callback and set task context'); | ||
test.done(); | ||
} | ||
}; |
18547
20
365
87