Skip to content

Commit

Permalink
shortcut include glob if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestalmage committed Dec 18, 2015
1 parent 1343d4a commit ca01f07
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ function NYC (opts) {
config = config.nyc || {}

// load exclude stanza from config.
this.include = arrify(config.include || ['**'])
this.include = this._prepGlobPatterns(this.include)
this.include = false
if (config.include) {
this.include = this._prepGlobPatterns(arrify(config.include))
}

this.exclude = ['**/node_modules/**'].concat(arrify(config.exclude || ['test/**', 'test{,-*}.js']))
this.exclude = this._prepGlobPatterns(this.exclude)
Expand Down Expand Up @@ -117,7 +119,7 @@ NYC.prototype.addFile = function (filename) {
NYC.prototype.shouldInstrumentFile = function (filename, relFile) {
relFile = relFile.replace(/^\.\//, '') // remove leading './'.

return (micromatch.any(filename, this.include) || micromatch.any(relFile, this.include)) &&
return (!this.include || micromatch.any(filename, this.include) || micromatch.any(relFile, this.include)) &&
!(micromatch.any(filename, this.exclude) || micromatch.any(relFile, this.exclude))
}

Expand Down

0 comments on commit ca01f07

Please sign in to comment.