@@ -12,7 +12,7 @@ var grunt = require('grunt'),
12
12
fs = require ( 'fs' ) ,
13
13
tempfile = require ( 'tempfile' ) ;
14
14
15
- function escape ( string ) {
15
+ var escape = function ( string ) {
16
16
return string . replace ( / [ - \/ \\ ^ $ * + ? . ( ) | [ \] { } ] / g, '\\$&' ) ;
17
17
}
18
18
@@ -58,23 +58,23 @@ function removePatterns(src, patterns) {
58
58
}
59
59
60
60
function createTemporaryFiles ( files , ignores , patterns ) {
61
- var map = { } ;
61
+ var temp = { } ;
62
+
62
63
files . forEach ( function ( filepath , index ) {
63
- var source = grunt . file . read ( filepath ) ;
64
+ var source = grunt . file . read ( filepath ) ,
65
+ tempFile = tempfile ( ) ;
64
66
65
- source = removeTags ( source , ignores ) ;
66
- source = removePatterns ( source , patterns ) ;
67
+ if ( ignores ) source = removeTags ( source , ignores ) ;
68
+ if ( patterns ) source = removePatterns ( source , patterns ) ;
67
69
68
70
if ( / ^ \s * $ / . test ( source ) ) return ;
69
71
70
- var file = tempfile ( ) ;
71
- fs . writeFileSync ( file , source ) ;
72
- map [ file ] = { filepath : filepath , file : { path : file } }
72
+ fs . writeFileSync ( tempFile , source ) ;
73
+ temp [ tempFile ] = { filepath : filepath , file : { path : tempFile } }
73
74
} ) ;
74
- return map ;
75
+ return temp ;
75
76
}
76
77
77
78
exports . lint = function lint ( options , files , ignores , patterns ) {
78
- var mapTemporary = createTemporaryFiles ( files , ignores , patterns || [ ] ) ;
79
- return mapTemporary ;
79
+ return createTemporaryFiles ( files , ignores , patterns || [ ] ) ;
80
80
} ;
0 commit comments