Skip to content

Commit

Permalink
Revert "fix: Exclude negated not working with '--all' switch (#977)"
Browse files Browse the repository at this point in the history
This reverts commit 91de23c.
  • Loading branch information
coreyfarrell committed Feb 22, 2019
1 parent 91de23c commit 8123693
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 69 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -6,5 +6,3 @@ test/build/
*.covered.js
*.swp
needs-transpile.js

!*test/fixtures/cli/include-exclude/node_modules/
21 changes: 8 additions & 13 deletions index.js
Expand Up @@ -2,7 +2,6 @@

/* global __coverage__ */

const arrayUniq = require('array-uniq')
const arrify = require('arrify')
const cachingTransform = require('caching-transform')
const util = require('util')
Expand Down Expand Up @@ -248,20 +247,16 @@ NYC.prototype.instrumentAllFiles = function (input, output, cb) {
}

NYC.prototype.walkAllFiles = function (dir, visitor) {
const pattern = (this.extensions.length === 1)
? `**/*${this.extensions[0]}`
: `**/*{${this.extensions.join()}}`

let filesToWalk = glob.sync(pattern, { cwd: dir, nodir: true, ignore: this.exclude.exclude })
var pattern = null
if (this.extensions.length === 1) {
pattern = '**/*' + this.extensions[0]
} else {
pattern = '**/*{' + this.extensions.join() + '}'
}

// package node-glob no longer observes negated excludes, so we need to restore these files ourselves
const excludeNegatedPaths = this.exclude.excludeNegated
excludeNegatedPaths.forEach(pattern => {
filesToWalk = filesToWalk.concat(glob.sync(pattern, { cwd: dir, nodir: true }))
glob.sync(pattern, { cwd: dir, nodir: true, ignore: this.exclude.exclude }).forEach(function (filename) {
visitor(filename)
})
filesToWalk = arrayUniq(filesToWalk)

filesToWalk.forEach(visitor)
}

NYC.prototype._maybeInstrumentSource = function (code, filename, relFile) {
Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -74,7 +74,6 @@
"license": "ISC",
"dependencies": {
"archy": "^1.0.0",
"array-uniq": "^2.0.0",
"arrify": "^1.0.1",
"caching-transform": "^3.0.1",
"convert-source-map": "^1.6.0",
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/cli/include-exclude/exclude-negated.js

This file was deleted.

2 changes: 0 additions & 2 deletions test/fixtures/cli/include-exclude/excluded.js

This file was deleted.

2 changes: 0 additions & 2 deletions test/fixtures/cli/include-exclude/node_modules/cover-me.js

This file was deleted.

42 changes: 0 additions & 42 deletions test/nyc-bin.js
Expand Up @@ -101,48 +101,6 @@ describe('the nyc cli', function () {
done()
})
})

it('should allow negated exclude patterns', function (done) {
const args = [bin, '--all', '--exclude', '**/include-exclude/**', '--exclude', '!**/exclude-negated.js', process.execPath, './half-covered.js']

const proc = spawn(process.execPath, args, {
cwd: fixturesCLI,
env: env
})

let stdout = ''
proc.stdout.on('data', chunk => {
stdout += chunk
})

proc.on('close', code => {
code.should.equal(0)
stdout.should.not.match(/excluded\.js/)
stdout.should.match(/exclude-negated\.js/)
done()
})
})

it('should include \'node_modules\' using exclude patterns', function (done) {
const args = [bin, '--all', '--exclude', '!**/node_modules/**', process.execPath, './half-covered.js']

const proc = spawn(process.execPath, args, {
cwd: fixturesCLI,
env: env
})

let stdout = ''
proc.stdout.on('data', chunk => {
stdout += chunk
})

proc.on('close', code => {
code.should.equal(0)
stdout.should.match(/include-exclude\/node_modules/)
stdout.should.match(/cover-me\.js/)
done()
})
})
})

describe('--ignore-class-method', function () {
Expand Down

0 comments on commit 8123693

Please sign in to comment.