Skip to content

Commit

Permalink
fix: _getIgnoredPatternsGlob
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 3, 2021
1 parent 120eb16 commit 5ef1d7d
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions lib/paths-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,16 +346,39 @@ export default class PathsCache extends EventEmitter {
/**
* Returns a list of ignore patterns for a directory
* @param {String} directoryPath
* @return {String[]}
* @returns {Array<string>} an array of glob patterns
* @private
*/
_getIgnorePatterns(directoryPath) {
_getIgnoredPatternsGlob(directoryPath) {
const patterns = []

if (this.config.shouldIgnoredNames) {
this.config.ignoredNames.forEach((pattern) => patterns.push(pattern))
patterns.push(...this.config.ignoredNames)
}

if (this.config.ignoredPatterns) {
patterns.push(...this.config.ignoredPatterns)
}

const patternsNum = patterns.length

let globEntries = new Array(patternsNum)

for (let iEntry = 0; iEntry < patternsNum; iEntry++) {
const globifyOutput = globifyPath(patterns[iEntry], directoryPath)

// Check if `globifyGitIgnoreEntry` returns a pair or a string
if (typeof globifyOutput === "string") {
// string
globEntries[iEntry] = globifyOutput // Place the entry in the output array
} else {
// pair
globEntries[iEntry] = globifyOutput[0] // Place the entry in the output array
globEntries.push(globifyOutput[1]) // Push the additional entry
}
}
return globEntries
}
if (this.config.excludeVcsIgnoredPaths) {
try {
const gitIgnore = fs.readFileSync(directoryPath + "/.gitignore", "utf-8")
Expand Down

0 comments on commit 5ef1d7d

Please sign in to comment.