Socket
Socket
Sign inDemoInstall

fast-glob

Package Overview
Dependencies
80
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.3 to 2.2.4

9

out/adapters/fs-stream.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

@@ -14,2 +14,3 @@ "use strict";

function sync(source, opts) {
assertPatternsInput(source);
var works = getWorks(source, reader_sync_1.default, opts);

@@ -23,2 +24,8 @@ return arrayUtils.flatten(works);

function async(source, opts) {
try {
assertPatternsInput(source);
}
catch (error) {
return Promise.reject(error);
}
var works = getWorks(source, reader_async_1.default, opts);

@@ -32,2 +39,3 @@ return Promise.all(works).then(arrayUtils.flatten);

function stream(source, opts) {
assertPatternsInput(source);
var works = getWorks(source, reader_stream_1.default, opts);

@@ -41,2 +49,3 @@ return merge2(works);

function generateTasks(source, opts) {
assertPatternsInput(source);
var patterns = [].concat(source);

@@ -57,1 +66,11 @@ var options = optionsManager.prepare(opts);

}
function assertPatternsInput(source) {
if ([].concat(source).every(isString)) {
return;
}
throw new TypeError('Patterns must be a string or an array of strings');
}
function isString(source) {
/* tslint:disable-next-line strict-type-predicates */
return typeof source === 'string';
}

@@ -33,10 +33,6 @@ import { Pattern, PatternsGroup } from '../types/patterns';

*/
export declare function convertPatternGroupsToTasks(positive: PatternsGroup, negative: PatternsGroup, dynamic: boolean): ITask[];
export declare function convertPatternGroupsToTasks(positive: PatternsGroup, negative: Pattern[], dynamic: boolean): ITask[];
/**
* Returns those negative patterns whose base paths includes positive base path or positive base path includes base paths.
*/
export declare function findLocalNegativePatterns(positiveBase: string, negative: PatternsGroup): Pattern[];
/**
* Create a task for positive and negative patterns.
*/
export declare function convertPatternGroupToTask(base: string, positive: Pattern[], negative: Pattern[], dynamic: boolean): ITask;
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -44,3 +24,2 @@ var patternUtils = require("../utils/pattern");

var positivePatternsGroup = groupPatternsByBaseDirectory(positive);
var negativePatternsGroup = groupPatternsByBaseDirectory(negative);
// When we have a global group – there is no reason to divide the patterns into independent tasks.

@@ -52,3 +31,3 @@ // In this case, the global task covers the rest.

}
return convertPatternGroupsToTasks(positivePatternsGroup, negativePatternsGroup, dynamic);
return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic);
}

@@ -92,7 +71,4 @@ exports.convertPatternsToTasks = convertPatternsToTasks;

function convertPatternGroupsToTasks(positive, negative, dynamic) {
var globalNegative = '.' in negative ? negative['.'] : [];
return Object.keys(positive).map(function (base) {
var localNegative = findLocalNegativePatterns(base, negative);
var fullNegative = localNegative.concat(globalNegative);
return convertPatternGroupToTask(base, positive[base], fullNegative, dynamic);
return convertPatternGroupToTask(base, positive[base], negative, dynamic);
});

@@ -102,14 +78,2 @@ }

/**
* Returns those negative patterns whose base paths includes positive base path or positive base path includes base paths.
*/
function findLocalNegativePatterns(positiveBase, negative) {
return Object.keys(negative).reduce(function (collection, base) {
if (base.startsWith(positiveBase) || positiveBase.startsWith(base)) {
collection.push.apply(collection, __spread(negative[base]));
}
return collection;
}, []);
}
exports.findLocalNegativePatterns = findLocalNegativePatterns;
/**
* Create a task for positive and negative patterns.

@@ -116,0 +80,0 @@ */

@@ -22,10 +22,6 @@ import micromatch = require('micromatch');

/**
* Returns «true» for directory that should be readed.
* Returns «true» for directory that should be read.
*/
private filter;
/**
* Returns «true» when the directory can be skipped by nesting level.
*/
private isSkippedByNestingLevel;
/**
* Returns «true» when the «deep» option is disabled or number and depth of the entry is greater that the option value.

@@ -32,0 +28,0 @@ */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var arrayUtils = require("../../utils/array");
var pathUtils = require("../../utils/path");

@@ -25,4 +24,3 @@ var patternUtils = require("../../utils/pattern");

var globstar = patterns.some(patternUtils.hasGlobStar);
var patternDepths = patterns.map(patternUtils.getDepth);
return globstar ? Infinity : arrayUtils.max(patternDepths);
return globstar ? Infinity : patternUtils.getMaxNaivePatternsDepth(patterns);
};

@@ -37,8 +35,11 @@ /**

/**
* Returns «true» for directory that should be readed.
* Returns «true» for directory that should be read.
*/
DeepFilter.prototype.filter = function (entry, negativeRe, maxPatternDepth) {
if (this.isSkippedByNestingLevel(entry.depth, maxPatternDepth)) {
if (this.isSkippedByDeepOption(entry.depth)) {
return false;
}
if (this.isSkippedByMaxPatternDepth(entry.depth, maxPatternDepth)) {
return false;
}
if (this.isSkippedSymlinkedDirectory(entry)) {

@@ -53,12 +54,6 @@ return false;

/**
* Returns «true» when the directory can be skipped by nesting level.
*/
DeepFilter.prototype.isSkippedByNestingLevel = function (entryDepth, maxPatternDepth) {
return this.isSkippedByDeepOption(entryDepth) || this.isSkippedByMaxPatternDepth(entryDepth, maxPatternDepth);
};
/**
* Returns «true» when the «deep» option is disabled or number and depth of the entry is greater that the option value.
*/
DeepFilter.prototype.isSkippedByDeepOption = function (entryDepth) {
return !this.options.deep || (typeof this.options.deep === 'number' && entryDepth > this.options.deep);
return !this.options.deep || (typeof this.options.deep === 'number' && entryDepth >= this.options.deep);
};

@@ -69,3 +64,3 @@ /**

DeepFilter.prototype.isSkippedByMaxPatternDepth = function (entryDepth, maxPatternDepth) {
return maxPatternDepth !== Infinity && entryDepth > maxPatternDepth;
return maxPatternDepth !== Infinity && entryDepth >= maxPatternDepth;
};

@@ -72,0 +67,0 @@ /**

@@ -35,2 +35,6 @@ import micromatch = require('micromatch');

/**
* Return true when `absolute` option is enabled and matched to the negative patterns.
*/
private isSkippedByAbsoluteNegativePatterns;
/**
* Return true when entry match to provided patterns.

@@ -37,0 +41,0 @@ *

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var pathUtils = require("../../utils/path");
var patternUtils = require("../../utils/pattern");

@@ -34,3 +35,6 @@ var DeepFilter = /** @class */ (function () {

}
return this.isMatchToPatterns(entry, positiveRe) && !this.isMatchToPatterns(entry, negativeRe);
if (this.isSkippedByAbsoluteNegativePatterns(entry, negativeRe)) {
return false;
}
return this.isMatchToPatterns(entry.path, positiveRe) && !this.isMatchToPatterns(entry.path, negativeRe);
};

@@ -62,2 +66,12 @@ /**

/**
* Return true when `absolute` option is enabled and matched to the negative patterns.
*/
DeepFilter.prototype.isSkippedByAbsoluteNegativePatterns = function (entry, negativeRe) {
if (!this.options.absolute) {
return false;
}
var fullpath = pathUtils.makeAbsolute(this.options.cwd, entry.path);
return this.isMatchToPatterns(fullpath, negativeRe);
};
/**
* Return true when entry match to provided patterns.

@@ -68,4 +82,4 @@ *

*/
DeepFilter.prototype.isMatchToPatterns = function (entry, patternsRe) {
return patternUtils.matchAny(entry.path, patternsRe) || patternUtils.matchAny(entry.path + '/', patternsRe);
DeepFilter.prototype.isMatchToPatterns = function (filepath, patternsRe) {
return patternUtils.matchAny(filepath, patternsRe) || patternUtils.matchAny(filepath + '/', patternsRe);
};

@@ -72,0 +86,0 @@ return DeepFilter;

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

@@ -48,9 +48,8 @@ "use strict";

Reader.prototype.transform = function (entry) {
if (this.options.absolute && !path.isAbsolute(entry.path)) {
entry.path = pathUtil.makeAbsolute(this.options.cwd, entry.path);
}
if (this.options.markDirectories && entry.isDirectory()) {
entry.path += '/';
}
if (this.options.absolute && !path.isAbsolute(entry.path)) {
entry.path = pathUtil.resolve(this.options.cwd, entry.path);
entry.path = pathUtil.normalize(entry.path);
}
var item = this.options.stats ? entry : entry.path;

@@ -57,0 +56,0 @@ if (this.options.transform === null) {

@@ -5,5 +5,1 @@ /**

export declare function flatten<T>(items: T[][]): T[];
/**
* Returns max number from array.
*/
export declare function max(items: Array<{}>): number;

@@ -10,8 +10,1 @@ "use strict";

exports.flatten = flatten;
/**
* Returns max number from array.
*/
function max(items) {
return Math.max.apply(null, items);
}
exports.max = max;

@@ -6,12 +6,8 @@ /**

/**
* Return naive depth of provided filepath.
* Convert a windows-like path to a unix-style path.
*/
export declare function getDepth(filepath: string): number;
export declare function normalize(filepath: string): string;
/**
* Return resolved a sequence of paths segments into an absolute path.
* Returns normalized absolute path of provided filepath.
*/
export declare function resolve(from: string, to: string): string;
/**
* Convert a windows-like path to a unix-style path.
*/
export declare function normalize(filepath: string): string;
export declare function makeAbsolute(cwd: string, filepath: string): string;

@@ -12,16 +12,2 @@ "use strict";

/**
* Return naive depth of provided filepath.
*/
function getDepth(filepath) {
return filepath.split('/').length;
}
exports.getDepth = getDepth;
/**
* Return resolved a sequence of paths segments into an absolute path.
*/
function resolve(from, to) {
return path.resolve(from, to);
}
exports.resolve = resolve;
/**
* Convert a windows-like path to a unix-style path.

@@ -33,1 +19,12 @@ */

exports.normalize = normalize;
/**
* Returns normalized absolute path of provided filepath.
*/
function makeAbsolute(cwd, filepath) {
if (path.isAbsolute(filepath)) {
return normalize(filepath);
}
var fullpath = path.resolve(cwd, filepath);
return normalize(fullpath);
}
exports.makeAbsolute = makeAbsolute;

@@ -56,6 +56,10 @@ import micromatch = require('micromatch');

/**
* Return naive depth of provided pattern.
* Return naive depth of provided pattern without depth of the base directory.
*/
export declare function getDepth(pattern: Pattern): number;
export declare function getNaiveDepth(pattern: Pattern): number;
/**
* Return max naive depth of provided patterns without depth of the base directory.
*/
export declare function getMaxNaivePatternsDepth(patterns: Pattern[]): number;
/**
* Make RegExp for provided pattern.

@@ -62,0 +66,0 @@ */

"use strict";
var __values = (this && this.__values) || function (o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -111,9 +101,30 @@ var path = require("path");

/**
* Return naive depth of provided pattern.
* Return naive depth of provided pattern without depth of the base directory.
*/
function getDepth(pattern) {
return pattern.split('/').length;
function getNaiveDepth(pattern) {
var base = getBaseDirectory(pattern);
var patternDepth = pattern.split('/').length;
var patternBaseDepth = base.split('/').length;
/**
* This is a hack for pattern that has no base directory.
*
* This is related to the `*\something\*` pattern.
*/
if (base === '.') {
return patternDepth - patternBaseDepth;
}
return patternDepth - patternBaseDepth - 1;
}
exports.getDepth = getDepth;
exports.getNaiveDepth = getNaiveDepth;
/**
* Return max naive depth of provided patterns without depth of the base directory.
*/
function getMaxNaivePatternsDepth(patterns) {
return patterns.reduce(function (max, pattern) {
var depth = getNaiveDepth(pattern);
return depth > max ? depth : max;
}, 0);
}
exports.getMaxNaivePatternsDepth = getMaxNaivePatternsDepth;
/**
* Make RegExp for provided pattern.

@@ -136,20 +147,4 @@ */

function matchAny(entry, patternsRe) {
var e_1, _a;
try {
for (var patternsRe_1 = __values(patternsRe), patternsRe_1_1 = patternsRe_1.next(); !patternsRe_1_1.done; patternsRe_1_1 = patternsRe_1.next()) {
var regexp = patternsRe_1_1.value;
if (regexp.test(entry)) {
return true;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (patternsRe_1_1 && !patternsRe_1_1.done && (_a = patternsRe_1.return)) _a.call(patternsRe_1);
}
finally { if (e_1) throw e_1.error; }
}
return false;
return patternsRe.some(function (patternRe) { return patternRe.test(entry); });
}
exports.matchAny = matchAny;
{
"name": "fast-glob",
"version": "2.2.3",
"version": "2.2.4",
"description": "Is a faster `node-glob` alternative",

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

"@types/compute-stdev": "^1.0.0",
"@types/easy-table": "0.0.31",
"@types/easy-table": "^0.0.32",
"@types/execa": "^0.9.0",
"@types/glob": "^5.0.35",
"@types/glob": "^7.1.1",
"@types/glob-parent": "^3.1.0",
"@types/glob-stream": "^6.1.0",
"@types/globby": "^6.1.0",
"@types/globby": "^8.0.0",
"@types/is-glob": "^4.0.0",

@@ -36,9 +36,9 @@ "@types/merge2": "^1.1.4",

"@types/minimist": "^1.2.0",
"@types/mocha": "^5.2.0",
"@types/node": "^9.6.6",
"@types/rimraf": "2.0.2",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.0",
"@types/rimraf": "^2.0.2",
"bash-glob": "^2.0.0",
"compute-stdev": "^1.0.0",
"easy-table": "^1.1.1",
"execa": "^0.10.0",
"execa": "^0.9.0",
"fast-glob": "^2.2.0",

@@ -49,14 +49,15 @@ "glob": "^7.1.2",

"minimist": "^1.2.0",
"mocha": "^5.1.1",
"mocha": "^5.2.0",
"rimraf": "^2.6.2",
"tslint": "^5.9.1",
"tiny-glob": "^0.2.3",
"tslint": "^5.11.0",
"tslint-config-mrmlnc": "^1.0.0",
"typescript": "^2.8.3"
"typescript": "^3.1.3"
},
"dependencies": {
"@mrmlnc/readdir-enhanced": "^2.2.1",
"@nodelib/fs.stat": "^1.0.1",
"@nodelib/fs.stat": "^1.1.2",
"glob-parent": "^3.1.0",
"is-glob": "^4.0.0",
"merge2": "^1.2.1",
"merge2": "^1.2.3",
"micromatch": "^3.1.10"

@@ -63,0 +64,0 @@ },

@@ -5,5 +5,2 @@ # :rocket: fast-glob

[![Build Status](https://travis-ci.org/mrmlnc/fast-glob.svg?branch=master)](https://travis-ci.org/mrmlnc/fast-glob)
[![Build status](https://ci.appveyor.com/api/projects/status/i4xqijtq26qf6o9d?svg=true)](https://ci.appveyor.com/project/mrmlnc/fast-glob)
## :bulb: Highlights

@@ -137,2 +134,25 @@

For example, you have the following tree:
```
test
└── one
└── two
└── index.js
```
> :book: If you specify a pattern with some base directory, this directory will not participate in the calculation of the depth of the found directories. Think of it as a `cwd` option.
```js
fg('test/**', { onlyFiles: false, deep: 0 });
// -> ['test/one']
fg('test/**', { onlyFiles: false, deep: 1 });
// -> ['test/one', 'test/one/two']
fg('**', { onlyFiles: false, cwd: 'test', deep: 0 });
// -> ['one']
fg('**', { onlyFiles: false, cwd: 'test', deep: 1 });
// -> ['one', 'one/two']
```
#### ignore

@@ -201,2 +221,4 @@

> :book: Note that you need to use this option if you want to use absolute negative patterns like `${__dirname}/*.md`.
#### nobrace

@@ -362,2 +384,3 @@

* [glob-stream](https://github.com/gulpjs/glob-stream) – A Readable Stream interface over node-glob that used in the [gulpjs](https://github.com/gulpjs/gulp).
* [tiny-glob](https://github.com/terkelg/tiny-glob) – Tiny and extremely fast library to match files and folders using glob patterns.

@@ -364,0 +387,0 @@ ## Changelog

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc