File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,12 @@ module.exports = function (grunt) {
10
10
var options = this . options ( {
11
11
encoding : 'utf8' ,
12
12
algorithm : 'md5' ,
13
- length : 8
13
+ length : 8 ,
14
+ dropCwd : false
14
15
} ) ;
15
16
var target = this . target ;
16
17
var filerev = grunt . filerev || { summary : { } } ;
18
+ var cwd = this . data . cwd || '' ;
17
19
18
20
eachAsync ( this . files , function ( el , i , next ) {
19
21
var move = true ;
@@ -60,13 +62,24 @@ module.exports = function (grunt) {
60
62
grunt . file . copy ( file , resultPath ) ;
61
63
}
62
64
63
- filerev . summary [ path . normalize ( file ) ] = path . join ( dirname , newName ) ;
65
+ filerev . summary [ fixPath ( path . normalize ( file ) ) ] = fixPath ( path . join ( dirname , newName ) ) ;
64
66
grunt . log . writeln ( chalk . green ( '✔ ' ) + file + chalk . gray ( ' changed to ' ) + newName ) ;
65
67
} ) ;
66
68
67
69
next ( ) ;
68
70
} , this . async ( ) ) ;
69
71
72
+ function fixPath ( path ) {
73
+ // Drop cwd from path if relative option is set to true
74
+ if ( options . dropCwd === true && cwd . length ) {
75
+ var pos = path . indexOf ( cwd ) ;
76
+ if ( pos === 0 ) {
77
+ path = path . slice ( cwd . length ) ;
78
+ }
79
+ }
80
+ return path ;
81
+ }
82
+
70
83
grunt . filerev = filerev ;
71
84
} ) ;
72
85
} ;
You can’t perform that action at this time.
0 commit comments