Skip to content

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
Remove arrayUniq as external dep
Return array processor at end of function
Drop use of let
*Better variable names
  • Loading branch information
Andrew Finlay committed Feb 21, 2019
1 parent d5d9b64 commit 0202ca7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
19 changes: 9 additions & 10 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 @@ -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) {
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

0 comments on commit 0202ca7

Please sign in to comment.