@humanwhocodes/config-array
Advanced tools
Comparing version 0.10.7 to 0.11.0
49
api.js
@@ -135,3 +135,3 @@ 'use strict'; | ||
*/ | ||
function doMatch(filepath, pattern, options) { | ||
function doMatch(filepath, pattern, options = {}) { | ||
@@ -147,3 +147,3 @@ let cache = minimatchCache; | ||
if (!matcher) { | ||
matcher = new Minimatch(pattern, options); | ||
matcher = new Minimatch(pattern, Object.assign({}, MINIMATCH_OPTIONS, options)); | ||
cache.set(pattern, matcher); | ||
@@ -298,3 +298,2 @@ } | ||
doMatch(relativeFilePath, matcher, { | ||
...MINIMATCH_OPTIONS, | ||
flipNegate: true | ||
@@ -305,3 +304,3 @@ })) { | ||
} else { | ||
shouldIgnore = shouldIgnore || doMatch(relativeFilePath, matcher, MINIMATCH_OPTIONS); | ||
shouldIgnore = shouldIgnore || doMatch(relativeFilePath, matcher); | ||
} | ||
@@ -342,3 +341,3 @@ | ||
if (isString(pattern)) { | ||
return doMatch(relativeFilePath, pattern, MINIMATCH_OPTIONS); | ||
return doMatch(relativeFilePath, pattern); | ||
} | ||
@@ -805,7 +804,47 @@ | ||
* @returns {boolean} True if the path is ignored, false if not. | ||
* @deprecated Use `isFileIgnored` instead. | ||
*/ | ||
isIgnored(filePath) { | ||
return this.isFileIgnored(filePath); | ||
} | ||
/** | ||
* Determines if the given filepath is ignored based on the configs. | ||
* @param {string} filePath The complete path of a file to check. | ||
* @returns {boolean} True if the path is ignored, false if not. | ||
*/ | ||
isFileIgnored(filePath) { | ||
return this.getConfig(filePath) === undefined; | ||
} | ||
/** | ||
* Determines if the given directory is ignored based on the configs. | ||
* This checks only default `ignores` that don't have `files` in the | ||
* same config. A pattern such as `/foo` be considered to ignore the directory | ||
* while a pattern such as `/foo/**` is not considered to ignore the | ||
* directory because it is matching files. | ||
* @param {string} directoryPath The complete path of a file to check. | ||
* @returns {boolean} True if the directory is ignored, false if not. | ||
*/ | ||
isDirectoryIgnored(directoryPath) { | ||
const normalizedDirectoryPath = directoryPath.endsWith("/") | ||
? directoryPath | ||
: directoryPath + "/"; | ||
return this.ignores.some(matcher => { | ||
if (typeof matcher === "function") { | ||
return matcher(normalizedDirectoryPath); | ||
} | ||
// patterns ending with ** never match directories | ||
if (matcher.endsWith("/**")) { | ||
return false; | ||
} | ||
return doMatch(normalizedDirectoryPath, matcher); | ||
}); | ||
} | ||
} | ||
@@ -812,0 +851,0 @@ |
# Changelog | ||
## [0.11.0](https://github.com/humanwhocodes/config-array/compare/v0.10.7...v0.11.0) (2022-09-30) | ||
### Features | ||
* Add isDirectoryIgnored; deprecated isIgnored ([e6942f2](https://github.com/humanwhocodes/config-array/commit/e6942f2ce075007d39f23530593b7adb19178a52)) | ||
## [0.10.7](https://github.com/humanwhocodes/config-array/compare/v0.10.6...v0.10.7) (2022-09-29) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@humanwhocodes/config-array", | ||
"version": "0.10.7", | ||
"version": "0.11.0", | ||
"description": "Glob-based configuration matching.", | ||
@@ -51,3 +51,3 @@ "author": "Nicholas C. Zakas", | ||
"@nitpik/node": "0.0.5", | ||
"chai": "4.2.0", | ||
"chai": "4.3.6", | ||
"eslint": "8.24.0", | ||
@@ -54,0 +54,0 @@ "esm": "3.2.25", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53615
688