Socket
Socket
Sign inDemoInstall

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 12.0.2 to 12.1.0

to-path.js

19

gitignore.js

@@ -1,2 +0,2 @@

import {promisify} from 'node:util';
import process from 'node:process';
import fs from 'node:fs';

@@ -7,2 +7,3 @@ import path from 'node:path';

import slash from 'slash';
import toPath from './to-path.js';

@@ -16,4 +17,2 @@ const DEFAULT_IGNORE = [

const readFileP = promisify(fs.readFile);
const mapGitIgnorePatternTo = base => ignore => {

@@ -66,3 +65,3 @@ if (ignore.startsWith('!')) {

const filePath = path.join(cwd, file);
const content = await readFileP(filePath, 'utf8');
const content = await fs.promises.readFile(filePath, 'utf8');

@@ -90,3 +89,3 @@ return {

cwd = slash(process.cwd()),
} = {}) => ({ignore, cwd});
} = {}) => ({ignore: [...DEFAULT_IGNORE, ...ignore], cwd: toPath(cwd)});

@@ -96,6 +95,3 @@ export const isGitIgnored = async options => {

const paths = await fastGlob('**/.gitignore', {
ignore: DEFAULT_IGNORE.concat(options.ignore),
cwd: options.cwd,
});
const paths = await fastGlob('**/.gitignore', options);

@@ -111,6 +107,3 @@ const files = await Promise.all(paths.map(file => getFile(file, options.cwd)));

const paths = fastGlob.sync('**/.gitignore', {
ignore: DEFAULT_IGNORE.concat(options.ignore),
cwd: options.cwd,
});
const paths = fastGlob.sync('**/.gitignore', options);

@@ -117,0 +110,0 @@ const files = paths.map(file => getFileSync(file, options.cwd));

@@ -15,3 +15,5 @@ import {Options as FastGlobOptions, Entry} from 'fast-glob';

export interface Options extends FastGlobOptions {
type FastGlobOptionsWithoutCwd = Omit<FastGlobOptions, 'cwd'>;
export interface Options extends FastGlobOptionsWithoutCwd {
/**

@@ -47,6 +49,13 @@ If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `Object` with `files` and `extensions` like in the example below.

readonly gitignore?: boolean;
/**
The current working directory in which to search.
@default process.cwd()
*/
readonly cwd?: URL | string;
}
export interface GitignoreOptions {
readonly cwd?: string;
readonly cwd?: URL | string;
readonly ignore?: readonly string[];

@@ -149,3 +158,10 @@ }

patterns: string | readonly string[],
options?: FastGlobOptions
options?: FastGlobOptionsWithoutCwd & {
/**
The current working directory in which to search.
@default process.cwd()
*/
readonly cwd?: URL | string;
}
): boolean;

@@ -152,0 +168,0 @@

@@ -6,2 +6,3 @@ import fs from 'node:fs';

import dirGlob from 'dir-glob';
import toPath from './to-path.js';
import {isGitIgnored, isGitIgnoredSync} from './gitignore.js';

@@ -20,3 +21,3 @@ import {FilterStream, UniqueStream} from './stream-utils.js';

const checkCwdOption = (options = {}) => {
const checkCwdOption = options => {
if (!options.cwd) {

@@ -40,6 +41,5 @@ return;

export const generateGlobTasks = (patterns, taskOptions) => {
export const generateGlobTasks = (patterns, taskOptions = {}) => {
patterns = arrayUnion([patterns].flat());
assertPatternsInput(patterns);
checkCwdOption(taskOptions);

@@ -52,4 +52,7 @@ const globTasks = [];

...taskOptions,
cwd: toPath(taskOptions.cwd),
};
checkCwdOption(taskOptions);
for (const [index, pattern] of patterns.entries()) {

@@ -186,5 +189,11 @@ if (isNegative(pattern)) {

export const isDynamicPattern = (patterns, options) => [patterns].flat()
.some(pattern => fastGlob.isDynamicPattern(pattern, options));
export const isDynamicPattern = (patterns, options = {}) => {
options = {
...options,
cwd: toPath(options.cwd),
};
return [patterns].flat().some(pattern => fastGlob.isDynamicPattern(pattern, options));
};
export {

@@ -191,0 +200,0 @@ isGitIgnored,

{
"name": "globby",
"version": "12.0.2",
"version": "12.1.0",
"description": "User-friendly glob matching",

@@ -20,4 +20,3 @@ "license": "MIT",

"bench": "npm update glob-stream fast-glob && matcha bench.js",
"//test": "xo && ava && tsd",
"test": "echo foo"
"test": "xo && ava && tsd"
},

@@ -28,3 +27,4 @@ "files": [

"gitignore.js",
"stream-utils.js"
"stream-utils.js",
"to-path.js"
],

@@ -68,3 +68,3 @@ "keywords": [

"fast-glob": "^3.2.7",
"ignore": "^5.1.8",
"ignore": "^5.1.9",
"merge2": "^1.4.1",

@@ -74,12 +74,12 @@ "slash": "^4.0.0"

"devDependencies": {
"@types/node": "^16.6.1",
"@types/node": "^16.11.11",
"ava": "^3.15.0",
"get-stream": "^6.0.1",
"glob-stream": "^6.1.0",
"glob-stream": "^7.0.0",
"globby": "sindresorhus/globby#main",
"matcha": "^0.7.0",
"rimraf": "^3.0.2",
"tsd": "^0.17.0",
"typescript": "^4.3.5",
"xo": "^0.44.0"
"tsd": "^0.19.0",
"typescript": "^4.5.2",
"xo": "^0.47.0"
},

@@ -86,0 +86,0 @@ "xo": {

@@ -14,2 +14,3 @@ # globby

- Supports `.gitignore`
- Supports `URL` as `cwd`

@@ -129,3 +130,3 @@ ## Install

Takes `cwd?: string` and `ignore?: string[]` as options. `.gitignore` files matched by the ignore config are not used for the resulting filter function.
Takes `cwd?: URL | string` and `ignore?: string[]` as options. `.gitignore` files matched by the ignore config are not used for the resulting filter function.

@@ -132,0 +133,0 @@ ```js

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