Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

globby

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

globby - npm Package Compare versions

Comparing version 13.0.0 to 13.1.0

ignore.js

9

index.d.ts

@@ -51,2 +51,11 @@ import {URL} from 'node:url'; // TODO: Remove this when https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34960 is fixed.

/**
Glob patterns to look for ignore files, which are then used to ignore globbed files.
This is a more generic form of the `gitignore` option, allowing you to find ignore files with a [compatible syntax](http://git-scm.com/docs/gitignore). For instance, this works with Babel's `.babelignore`, Prettier's `.prettierignore`, or ESLint's `.eslintignore` files.
@default undefined
*/
readonly ignoreFiles?: string | string[];
/**
The current working directory in which to search.

@@ -53,0 +62,0 @@

45

index.js

@@ -5,9 +5,11 @@ import fs from 'node:fs';

import dirGlob from 'dir-glob';
import {isGitIgnored, isGitIgnoredSync} from './gitignore.js';
import {FilterStream, toPath} from './utilities.js';
import {
GITIGNORE_FILES_PATTERN,
isIgnoredByIgnoreFiles,
isIgnoredByIgnoreFilesSync,
} from './ignore.js';
import {FilterStream, toPath, isNegativePattern} from './utilities.js';
const isNegative = pattern => pattern[0] === '!';
const assertPatternsInput = patterns => {
if (!patterns.every(pattern => typeof pattern === 'string')) {
if (patterns.some(pattern => typeof pattern !== 'string')) {
throw new TypeError('Patterns must be a string or an array of strings');

@@ -56,10 +58,27 @@ }

const getFilter = async options => createFilterFunction(
options.gitignore && await isGitIgnored({cwd: options.cwd}),
);
const getIgnoreFilesPatterns = options => {
const {ignoreFiles, gitignore} = options;
const getFilterSync = options => createFilterFunction(
options.gitignore && isGitIgnoredSync({cwd: options.cwd}),
);
const patterns = ignoreFiles ? toPatternsArray(ignoreFiles) : [];
if (gitignore) {
patterns.push(GITIGNORE_FILES_PATTERN);
}
return patterns;
};
const getFilter = async options => {
const ignoreFilesPatterns = getIgnoreFilesPatterns(options);
return createFilterFunction(
ignoreFilesPatterns.length > 0 && await isIgnoredByIgnoreFiles(ignoreFilesPatterns, {cwd: options.cwd}),
);
};
const getFilterSync = options => {
const ignoreFilesPatterns = getIgnoreFilesPatterns(options);
return createFilterFunction(
ignoreFilesPatterns.length > 0 && isIgnoredByIgnoreFilesSync(ignoreFilesPatterns, {cwd: options.cwd}),
);
};
const createFilterFunction = isIgnored => {

@@ -83,3 +102,3 @@ const seen = new Set();

while (patterns.length > 0) {
const index = patterns.findIndex(pattern => isNegative(pattern));
const index = patterns.findIndex(pattern => isNegativePattern(pattern));

@@ -209,2 +228,2 @@ if (index === -1) {

isGitIgnoredSync,
} from './gitignore.js';
} from './ignore.js';
{
"name": "globby",
"version": "13.0.0",
"version": "13.1.0",
"description": "User-friendly glob matching",

@@ -25,3 +25,3 @@ "license": "MIT",

"index.d.ts",
"gitignore.js",
"ignore.js",
"utilities.js"

@@ -28,0 +28,0 @@ ],

@@ -13,3 +13,3 @@ # globby

- Expands directories: `foo` → `foo/**/*`
- Supports `.gitignore`
- Supports `.gitignore` and similar ignore config files
- Supports `URL` as `cwd`

@@ -92,2 +92,11 @@

##### ignoreFiles
Type: `string | string[]`\
Default: `undefined`
Glob patterns to look for ignore files, which are then used to ignore globbed files.
This is a more generic form of the `gitignore` option, allowing you to find ignore files with a [compatible syntax](http://git-scm.com/docs/gitignore). For instance, this works with Babel's `.babelignore`, Prettier's `.prettierignore`, or ESLint's `.eslintignore` files.
### globbySync(patterns, options?)

@@ -94,0 +103,0 @@

@@ -16,1 +16,3 @@ import {fileURLToPath} from 'node:url';

}
export const isNegativePattern = pattern => pattern[0] === '!';
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