diff --git a/index.js b/index.js index 122ed8a12..02662b8d3 100755 --- a/index.js +++ b/index.js @@ -2,7 +2,6 @@ /* global __coverage__ */ -const arrayUniq = require('array-uniq') const arrify = require('arrify') const cachingTransform = require('caching-transform') const util = require('util') @@ -243,20 +242,20 @@ NYC.prototype.instrumentAllFiles = function (input, output, cb) { } NYC.prototype.walkAllFiles = function (dir, visitor) { - const pattern = (this.extensions.length === 1) + const sourceGlob = (this.extensions.length === 1) ? `**/*${this.extensions[0]}` : `**/*{${this.extensions.join()}}` - let filesToWalk = glob.sync(pattern, { cwd: dir, nodir: true, ignore: this.exclude.exclude }) + const arrayUniq = x => [...new Set(x)] - // 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 })) - }) - filesToWalk = arrayUniq(filesToWalk) + // Package node-glob no longer observes negated excludes, so we need to restore these files + const unExcludeFiles = this.exclude.excludeNegated.reduce( + (acc, negExcludeGlob) => acc.concat(glob.sync(negExcludeGlob, { cwd: dir, nodir: true })), + [] + ) + const filesLessExcludes = glob.sync(sourceGlob, { cwd: dir, nodir: true, ignore: this.exclude.exclude }) - filesToWalk.forEach(visitor) + return arrayUniq(filesLessExcludes.concat(unExcludeFiles)).forEach(visitor) } NYC.prototype._maybeInstrumentSource = function (code, filename, relFile) { diff --git a/package-lock.json b/package-lock.json index 9f59fa7fe..f35957e52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -216,11 +216,6 @@ "es-abstract": "^1.7.0" } }, - "array-uniq": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-2.0.0.tgz", - "integrity": "sha512-O3QZEr+3wDj7otzF7PjNGs6CA3qmYMLvt5xGkjY/V0VxS+ovvqVo/5wKM/OVOAyuX4DTh9H31zE/yKtO66hTkg==" - }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", diff --git a/package.json b/package.json index 0dbd92144..1d6a73815 100644 --- a/package.json +++ b/package.json @@ -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",