Skip to content
This repository was archived by the owner on Mar 26, 2018. It is now read-only.

Commit e7ddab5

Browse files
committed
Tweaks
1 parent d349a03 commit e7ddab5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tasks/filerev.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ var eachAsync = require('each-async');
77

88
module.exports = function (grunt) {
99
grunt.registerMultiTask('filerev', 'File revisioning based on content hashing', function () {
10+
var target = this.target;
11+
var filerev = grunt.filerev || {summary: {}};
1012
var options = this.options({
1113
algorithm: 'md5',
1214
length: 8
1315
});
14-
var target = this.target;
15-
var filerev = grunt.filerev || {summary: {}};
1616

1717
eachAsync(this.files, function (el, i, next) {
1818
var move = true;
@@ -26,6 +26,7 @@ module.exports = function (grunt) {
2626

2727
try {
2828
var stat = fs.lstatSync(el.dest);
29+
2930
if (stat && !stat.isDirectory()) {
3031
grunt.fail.fatal('Destination ' + el.dest + ' for target ' + target + ' is not a directory');
3132
}
@@ -72,9 +73,11 @@ module.exports = function (grunt) {
7273

7374
// Source maps
7475
var sourceMap = false;
76+
7577
if (ext === '.js' || ext === '.css') {
7678
var map = file + '.map';
7779
var resultPathMap = resultPath + '.map';
80+
7881
if (grunt.file.exists(map)) {
7982
if (move) {
8083
fs.renameSync(map, resultPathMap);
@@ -92,11 +95,11 @@ module.exports = function (grunt) {
9295

9396
filerev.summary[path.normalize(file)] = path.join(dirname, newName);
9497
grunt.verbose.writeln(chalk.green('✔ ') + file + chalk.gray(' changed to ') + newName);
98+
9599
if (sourceMap) {
96100
filerev.summary[path.normalize(file + '.map')] = path.join(dirname, newName + '.map');
97101
grunt.verbose.writeln(chalk.green('✔ ') + file + '.map' + chalk.gray(' changed to ') + newName + '.map');
98102
}
99-
100103
});
101104

102105
grunt.log.writeln('Revved ' + chalk.cyan(el.src.length) + ' ' +

0 commit comments

Comments
 (0)