Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: Exclude negated not working with '--all' switch" #998

Merged
merged 1 commit into from Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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