Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ module.exports = function(grunt) {
},
src: ['tmp/international.txt']
},
summary_options: {
options: {
summary: 'tmp/rev_summary.js'
},
src: ['tmp/revsummary.txt']
}
},

// Unit tests.
Expand Down
6 changes: 5 additions & 1 deletion tasks/rev.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = function(grunt) {
algorithm: 'md5',
length: 8
});
var summary = {};

this.files.forEach(function(filePair) {
filePair.src.forEach(function(f) {
Expand All @@ -36,14 +37,17 @@ module.exports = function(grunt) {
prefix = hash.slice(0, options.length),
renamed = [prefix, path.basename(f)].join('.'),
outPath = path.resolve(path.dirname(f), renamed);

summary[f] = path.join(path.dirname(f), renamed);
grunt.verbose.ok().ok(hash);
fs.renameSync(f, outPath);
grunt.log.write(f + ' ').ok(renamed);

});
});

if (options.summary) {
grunt.file.write(options.summary, JSON.stringify(summary));
}
});

};
1 change: 1 addition & 0 deletions test/fixtures/revsummary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The quick brown fox jumps over the lazy dog
10 changes: 10 additions & 0 deletions test/rev_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ exports.rev = {
var exists = grunt.file.exists('tmp/faa07745.international.txt');
test.ok(exists, '8 character MD5 hash prefix for international content');

test.done();
},
rev_summary_options: function(test) {
test.expect(2);

var exists = grunt.file.exists('tmp/rev_summary.js');
test.ok(exists, 'summary file produced');

var summary = grunt.file.readJSON('tmp/rev_summary.js');
test.equal(summary['tmp/revsummary.txt'], 'tmp/9e107d9d.revsummary.txt');
test.done();
}
};