grunt-update-reference
Advanced tools
Comparing version
@@ -8,5 +8,4 @@ 'use strict'; | ||
options:{ | ||
searchFileType: [ "html", "css", "js" ], | ||
ignoreSearchFile:"", | ||
ignoreSearchPath:"", | ||
searchFileType: [ "*.html", "*.js", "*.css" ], | ||
ignore:"", | ||
newer:true | ||
@@ -24,6 +23,4 @@ }, | ||
options: { | ||
searchFileType: [ "html", "css", "js" ], | ||
ignoreSearchFile: "", | ||
ignoreSearchPath: "" | ||
}, | ||
@@ -41,3 +38,5 @@ dist: { | ||
grunt.registerMultiTask( "test", function () { | ||
console.dir(this) | ||
//console.dir(this) | ||
console.log(grunt.file.match( { matchBase: true },[".*"], ".Gruntfile.js" ).length) | ||
} ); | ||
@@ -44,0 +43,0 @@ grunt.loadTasks('./tasks'); |
@@ -9,8 +9,7 @@ | ||
* @param newFileName array 那些有更新的文件的文件名 | ||
* @param regFileType regex 那些需要检测内容是否含有"newFileName"的文件的文件类型 | ||
* @param regIgnoreFile regex 忽略的文件 | ||
* @param regIgnorePath regex 忽略的路径 | ||
* @param fileType Minimatch 那些需要检测内容是否含有"newFileName"的文件的文件类型 | ||
* @param ignore Minimatch these files or paths will ignore | ||
* | ||
*/ | ||
module.exports.upd = function ( path, newFileName, regFileType, regIgnoreFile, regIgnorePath ) { | ||
module.exports.upd = function ( path, newFileName, fileType, ignore ) { | ||
var regLineHeadSpace = /^ +/; | ||
@@ -28,7 +27,5 @@ var nowTime = new Date().getTime(); | ||
grunt.file.recurse( path, function ( abspath, rootdir, subdir, filename ) { | ||
if ( regIgnorePath.test( abspath ) ) {return} | ||
if ( regIgnoreFile.test( filename ) ) {return} | ||
//是需要修改内容的文件 | ||
if ( !regFileType.test( filename ) ) {return} | ||
if(grunt.file.match( { matchBase: true }, ignore, abspath ).length>0){return} | ||
if(grunt.file.match( { matchBase: true }, fileType, filename ).length===0){return} | ||
@@ -35,0 +32,0 @@ var i; |
{ | ||
"name": "grunt-update-reference", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "devDependencies": { |
@@ -7,13 +7,2 @@ | ||
function convertMatcher( tar ) { | ||
var kind = grunt.util.kindOf( tar ); | ||
if ( kind === "array" ) { | ||
return new RegExp( tar.join( "|" ) ); | ||
}else if(kind === "string"){ | ||
return new RegExp( tar ); | ||
} | ||
return tar; | ||
} | ||
/** | ||
@@ -25,3 +14,4 @@ * @taskName 任务reference_core的任务名,为何要搞多一个呢,因为用来骗grunt-newer识别并纪录时间戳, 保证不同的任务区分开来, | ||
var opt = this.options( { | ||
newer: true | ||
newer: true, | ||
searchFileType: [ "*.html", "*.js", "*.css" ] | ||
} ); | ||
@@ -45,5 +35,4 @@ var newer = opt.newer?"newer:":""; | ||
var searchPathBase = opt.searchPathBase; | ||
var searchFileType = convertMatcher(opt.searchFileType || /htm|css|js/); | ||
var ignoreSearchFile = convertMatcher(opt.ignoreSearchFile || /Gruntfile|(^\.)/); | ||
var ignoreSearchPath = convertMatcher(opt.ignoreSearchPath || /node_modules|(^\.)/); | ||
var searchFileType = opt.searchFileType; | ||
var ignore = opt.ignore || ["node_modules/**/*",".*/**/*",".*","Gruntfile.js"]; | ||
var newFileName = []; | ||
@@ -64,3 +53,3 @@ | ||
} | ||
version.upd( searchPathBase, newFileName, searchFileType, ignoreSearchFile, ignoreSearchPath ); | ||
version.upd( searchPathBase, newFileName, searchFileType, ignore ); | ||
@@ -67,0 +56,0 @@ } ); |
+function () { | ||
//reference css file; | ||
var css = "./base.css?t=1456062175493", | ||
xcss = "./xcss/base.css?t=1456062175493"; | ||
var css = "./base.css?t=1456071676251", | ||
xcss = "./xcss/base.css?t=1456071676251"; | ||
}(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
13
8.33%30121
-1.64%177
-7.81%