Socket
Socket
Sign inDemoInstall

@humanwhocodes/config-array

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@humanwhocodes/config-array - npm Package Compare versions

Comparing version 0.11.1 to 0.11.2

65

api.js

@@ -431,7 +431,7 @@ 'use strict';

constructor(configs, {
basePath = '',
normalized = false,
schema: customSchema,
extraConfigTypes = []
} = {}
basePath = '',
normalized = false,
schema: customSchema,
extraConfigTypes = []
} = {}
) {

@@ -485,3 +485,6 @@ super();

dataCache.set(this, {
explicitMatches: new Map()
explicitMatches: new Map(),
directoryMatches: new Map(),
files: undefined,
ignores: undefined
});

@@ -730,2 +733,11 @@

// check if this should be ignored due to its directory
if (this.isDirectoryIgnored(path.dirname(filePath))) {
debug(`Ignoring ${filePath} based on directory pattern`);
// cache and return result - finalConfig is undefined at this point
cache.set(filePath, finalConfig);
return finalConfig;
}
// TODO: Maybe move elsewhere?

@@ -735,3 +747,3 @@ const relativeFilePath = path.relative(this.basePath, filePath);

if (shouldIgnoreFilePath(this.ignores, filePath, relativeFilePath)) {
debug(`Ignoring ${filePath}`);
debug(`Ignoring ${filePath} based on file pattern`);

@@ -824,19 +836,32 @@ // cache and return result - finalConfig is undefined at this point

* 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.
* @param {string} directoryPath The complete path of a directory to check.
* @returns {boolean} True if the directory is ignored, false if not. Will
* return true for any directory that is not inside of `basePath`.
* @throws {Error} When the `ConfigArray` is not normalized.
*/
isDirectoryIgnored(directoryPath) {
const normalizedDirectoryPath = directoryPath.endsWith("/")
? directoryPath
: directoryPath + "/";
assertNormalized(this);
return this.ignores.some(matcher => {
const relativeDirectoryPath = path.relative(this.basePath, directoryPath) + '/';
if (relativeDirectoryPath.startsWith('..')) {
return true;
}
if (typeof matcher === "function") {
return matcher(normalizedDirectoryPath);
// first check the cache
const cache = dataCache.get(this).directoryMatches;
if (cache.has(relativeDirectoryPath)) {
return cache.get(relativeDirectoryPath);
}
// if we've made it here, it means there's nothing in the cache
const result = this.ignores.some(matcher => {
if (typeof matcher === 'function') {
return matcher(relativeDirectoryPath);
}
// skip negated patterns because you can't unignore directories
if (matcher.startsWith("!")) {
if (matcher.startsWith('!')) {
return false;

@@ -846,8 +871,12 @@ }

// patterns ending with ** never match directories
if (matcher.endsWith("/**")) {
if (matcher.endsWith('/**')) {
return false;
}
return doMatch(normalizedDirectoryPath, matcher);
return doMatch(relativeDirectoryPath, matcher);
});
cache.set(relativeDirectoryPath, result);
return result;
}

@@ -854,0 +883,0 @@

# Changelog
## [0.11.2](https://github.com/humanwhocodes/config-array/compare/v0.11.1...v0.11.2) (2022-10-03)
### Bug Fixes
* Error conditions for isDirectoryIgnored ([0bd81f5](https://github.com/humanwhocodes/config-array/commit/0bd81f53b7c217d561f70709057c7d77f17e8c6d))
* isDirectoryIgnored should match on relative path. ([3d1eaf6](https://github.com/humanwhocodes/config-array/commit/3d1eaf6389056215e27793cde9c2954c01c78df8))
* isFileIgnored should call isDirectoryIgnored ([270d359](https://github.com/humanwhocodes/config-array/commit/270d359295f376edb0c73905f62a848284d34053))
### Performance Improvements
* Cache isDirectoryIgnored calls ([c5e6720](https://github.com/humanwhocodes/config-array/commit/c5e67208618e253c08bd320efeae4b1f63641e63))
## [0.11.1](https://github.com/humanwhocodes/config-array/compare/v0.11.0...v0.11.1) (2022-09-30)

@@ -4,0 +18,0 @@

{
"name": "@humanwhocodes/config-array",
"version": "0.11.1",
"version": "0.11.2",
"description": "Glob-based configuration matching.",

@@ -22,2 +22,3 @@ "author": "Nicholas C. Zakas",

"lint": "eslint *.config.js src/*.js tests/*.js",
"lint:fix": "eslint --fix *.config.js src/*.js tests/*.js",
"prepublish": "npm run build",

@@ -24,0 +25,0 @@ "test:coverage": "nyc --include src/*.js npm run test",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc