@ -99,12 +99,15 @@ function test (file, excludeList) {
// chop the filename down to be relative to excludeDir
// chop the filename down to be relative to excludeDir
var rf = relativize ( file , dir , true )
var rf = relativize ( file , dir , true )
rf = rf . replace ( /^\.?\// , "" )
rf = rf . replace ( /^\.?\// , "" )
if ( file . slice ( - 1 ) === "/" ) rf += "/"
// log.warn([file, rf], "rf")
for ( var ii = 0 , ll = excludes . length ; ii < ll ; ii ++ ) {
for ( var ii = 0 , ll = excludes . length ; ii < ll ; ii ++ ) {
//log.warn(JSON.stringify(excludes[ii]), "ex")
var ex = excludes [ ii ] . replace ( /^(!*)\// , "$1" )
var ex = excludes [ ii ] . replace ( /^(!*)\.\// , "$1" )
, inc = ! ! ex . match ( incRe )
, inc = ! ! ex . match ( incRe )
// log.warn([ex, rf], "ex, rf")
// excluding/including a dir excludes/includes all the files in it.
// excluding/including a dir excludes/includes all the files in it.
if ( ex . slice ( - 1 ) === "/" ) ex += "**"
if ( ex . slice ( - 1 ) === "/" ) ex += "**"
@ -118,20 +121,27 @@ function test (file, excludeList) {
if ( inc && ! excluded ) continue
if ( inc && ! excluded ) continue
// if it matches the pattern, then it should be excluded.
// if it matches the pattern, then it should be excluded.
excluded = ! ! minimatch ( rf , ex , { baseMatch : true } )
excluded = ! ! minimatch ( rf , ex , { matchBase : true } )
//if (inc) excluded = !excluded
// log.error([rf, ex, excluded], "rf, ex, excluded")
//if (excluded) {
// console.error("excluded %s %s", rf, ex)
//}
// if you include foo, then it also includes foo/bar.js
// if you include foo, then it also includes foo/bar.js
if ( inc && excluded && ex . slice ( - 3 ) !== "/**" ) {
if ( inc && excluded && ex . slice ( - 3 ) !== "/**" ) {
excluded = minimatch ( rf , ex + "/**" , { baseMatch : true } )
excluded = minimatch ( rf , ex + "/**" , { matchBase : true } )
// console.error(rf, ex + "/**", inc, excluded)
// log.warn([rf, ex + "/**", inc, excluded], "dir without /")
}
// if you exclude foo, then it also excludes foo/bar.js
if ( ! inc
&& excluded
&& ex . slice ( - 3 ) !== "/**"
&& rf . slice ( - 1 ) === "/"
&& excludes . indexOf ( ex + "/**" ) === - 1 ) {
// log.warn(ex + "/**", "adding dir-matching exclude pattern")
excludes . push ( ex + "/**" )
ll ++
}
}
}
}
//log.warn([rf, excluded, excludes], "file, excluded, excludes")
// log.warn([rf, excluded, excludes], "r f, excluded, excludes")
}
}
// true if it *should* be included
// true if it *should* be included
// log.warn([file, excludeList, excluded], "file, excluded")
// log.warn([file, excludeList, excluded], "file, excluded")
@ -141,5 +151,7 @@ function test (file, excludeList) {
// returns a function suitable for Array#filter
// returns a function suitable for Array#filter
function filter ( dir , list ) { return function ( file ) {
function filter ( dir , list ) { return function ( file ) {
file = file . trim ( )
file = file . trim ( )
return file && test ( path . resolve ( dir , file ) , list )
var testFile = path . resolve ( dir , file )
if ( file . slice ( - 1 ) === "/" ) testFile += "/"
return file && test ( testFile , list )
} }
} }