Comparing version 0.0.2 to 0.0.3
@@ -6,2 +6,3 @@ var esprima = require('esprima'); | ||
var Vow = require('vow'); | ||
var minimatch = require('minimatch'); | ||
@@ -11,3 +12,3 @@ var Checker = function() { | ||
this._activeRules = []; | ||
this._config = {}; | ||
this._excludes = null; | ||
}; | ||
@@ -37,3 +38,2 @@ | ||
configure: function(config) { | ||
this._config = config; | ||
var activeRules = this._activeRules; | ||
@@ -47,2 +47,5 @@ this._rules.forEach(function(rule) { | ||
}); | ||
this._excludes = (config.exclude_files || []).map(function(pattern) { | ||
return new minimatch.Minimatch(pattern); | ||
}); | ||
}, | ||
@@ -66,5 +69,9 @@ checkString: function(str, filename) { | ||
var _this = this; | ||
return vowFs.read(path, 'utf8').then(function (data) { | ||
return _this.checkString(data, path); | ||
}); | ||
if (this._shouldProcess(path) && path.match(/\.js$/)) { | ||
return vowFs.read(path, 'utf8').then(function (data) { | ||
return _this.checkString(data, path); | ||
}); | ||
} else { | ||
return null; | ||
} | ||
}, | ||
@@ -78,6 +85,16 @@ checkDirectory: function(path) { | ||
return vowFs.stat(fullname).then(function(stat) { | ||
if (stat.isDirectory()) { | ||
return _this.checkDirectory(fullname); | ||
} else if (fullname.match(/\.js$/)) { | ||
return _this.checkFile(fullname); | ||
if (_this._shouldProcess(fullname)) { | ||
if (stat.isDirectory()) { | ||
return _this.checkDirectory(fullname); | ||
} else if (fullname.match(/\.js$/)) { | ||
return Vow.when(_this.checkFile(fullname)).then(function(errors) { | ||
if (errors) { | ||
return errors; | ||
} else { | ||
return []; | ||
} | ||
}); | ||
} else { | ||
return []; | ||
} | ||
} else { | ||
@@ -109,2 +126,12 @@ return []; | ||
}); | ||
}, | ||
_shouldProcess: function(path) { | ||
path = path.replace(/^\.\//, ''); | ||
var excludes = this._excludes; | ||
for (var i = 0, l = excludes.length; i < l; i++) { | ||
if (excludes[i].match(path)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
@@ -111,0 +138,0 @@ }; |
@@ -65,3 +65,3 @@ var colors = require('colors'); | ||
' at ' + | ||
(colorize ? colors.green(filename) : filename); | ||
(colorize ? colors.green(filename) : filename) + ':'; | ||
} | ||
@@ -68,0 +68,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"name" : "jscs", | ||
"version" : "0.0.2", | ||
"version" : "0.0.3", | ||
"repository" : "https://github.com/mdevils/jscs", | ||
@@ -22,3 +22,4 @@ "contributors" : [ | ||
"colors": "0.6.0-1", | ||
"commander": "1.2.0" | ||
"commander": "1.2.0", | ||
"minimatch": "0.2.12" | ||
}, | ||
@@ -25,0 +26,0 @@ "devDependencies" : { |
@@ -263,4 +263,10 @@ node-jscs | ||
"require_param_types": true | ||
} | ||
}, | ||
/* | ||
Option: exclude_files | ||
Disables style checking for specified paths. | ||
*/ | ||
"exclude_files": ["node_modules/**"] | ||
} | ||
Sorry, the diff of this file is not supported yet
61615
1455
272
6
+ Addedminimatch@0.2.12
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.2.12(transitive)
+ Addedsigmund@1.0.1(transitive)