Comparing version 3.2.5 to 3.2.6
@@ -11,2 +11,8 @@ import Settings from '../settings'; | ||
export declare function generate(patterns: Pattern[], settings: Settings): Task[]; | ||
/** | ||
* Returns tasks grouped by basic pattern directories. | ||
* | ||
* Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately. | ||
* This is necessary because directory traversal starts at the base directory and goes deeper. | ||
*/ | ||
export declare function convertPatternsToTasks(positive: Pattern[], negative: Pattern[], dynamic: boolean): Task[]; | ||
@@ -13,0 +19,0 @@ export declare function getPositivePatterns(patterns: Pattern[]): Pattern[]; |
@@ -15,11 +15,26 @@ "use strict"; | ||
exports.generate = generate; | ||
/** | ||
* Returns tasks grouped by basic pattern directories. | ||
* | ||
* Patterns that can be found inside (`./`) and outside (`../`) the current directory are handled separately. | ||
* This is necessary because directory traversal starts at the base directory and goes deeper. | ||
*/ | ||
function convertPatternsToTasks(positive, negative, dynamic) { | ||
const positivePatternsGroup = groupPatternsByBaseDirectory(positive); | ||
// When we have a global group – there is no reason to divide the patterns into independent tasks. | ||
// In this case, the global task covers the rest. | ||
if ('.' in positivePatternsGroup) { | ||
const task = convertPatternGroupToTask('.', positive, negative, dynamic); | ||
return [task]; | ||
const tasks = []; | ||
const patternsOutsideCurrentDirectory = utils.pattern.getPatternsOutsideCurrentDirectory(positive); | ||
const patternsInsideCurrentDirectory = utils.pattern.getPatternsInsideCurrentDirectory(positive); | ||
const outsideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsOutsideCurrentDirectory); | ||
const insideCurrentDirectoryGroup = groupPatternsByBaseDirectory(patternsInsideCurrentDirectory); | ||
tasks.push(...convertPatternGroupsToTasks(outsideCurrentDirectoryGroup, [], dynamic)); | ||
/* | ||
* For the sake of reducing future accesses to the file system, we merge all tasks within the current directory | ||
* into a global task, if at least one pattern refers to the root (`.`). In this case, the global task covers the rest. | ||
*/ | ||
if ('.' in insideCurrentDirectoryGroup) { | ||
tasks.push(convertPatternGroupToTask('.', patternsInsideCurrentDirectory, negative, dynamic)); | ||
} | ||
return convertPatternGroupsToTasks(positivePatternsGroup, negative, dynamic); | ||
else { | ||
tasks.push(...convertPatternGroupsToTasks(insideCurrentDirectoryGroup, negative, dynamic)); | ||
} | ||
return tasks; | ||
} | ||
@@ -26,0 +41,0 @@ exports.convertPatternsToTasks = convertPatternsToTasks; |
@@ -15,2 +15,19 @@ import { MicromatchOptions, Pattern, PatternRe } from '../types'; | ||
export declare function getPositivePatterns(patterns: Pattern[]): Pattern[]; | ||
/** | ||
* Returns patterns that can be applied inside the current directory. | ||
* | ||
* @example | ||
* // ['./*', '*', 'a/*'] | ||
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*']) | ||
*/ | ||
export declare function getPatternsInsideCurrentDirectory(patterns: Pattern[]): Pattern[]; | ||
/** | ||
* Returns patterns to be expanded relative to (outside) the current directory. | ||
* | ||
* @example | ||
* // ['../*', './../*'] | ||
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*']) | ||
*/ | ||
export declare function getPatternsOutsideCurrentDirectory(patterns: Pattern[]): Pattern[]; | ||
export declare function isPatternRelatedToParentDirectory(pattern: Pattern): boolean; | ||
export declare function getBaseDirectory(pattern: Pattern): string; | ||
@@ -17,0 +34,0 @@ export declare function hasGlobStar(pattern: Pattern): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0; | ||
exports.matchAny = exports.convertPatternsToRe = exports.makeRe = exports.getPatternParts = exports.expandBraceExpansion = exports.expandPatternsWithBraceExpansion = exports.isAffectDepthOfReadingPattern = exports.endsWithSlashGlobStar = exports.hasGlobStar = exports.getBaseDirectory = exports.isPatternRelatedToParentDirectory = exports.getPatternsOutsideCurrentDirectory = exports.getPatternsInsideCurrentDirectory = exports.getPositivePatterns = exports.getNegativePatterns = exports.isPositivePattern = exports.isNegativePattern = exports.convertToNegativePattern = exports.convertToPositivePattern = exports.isDynamicPattern = exports.isStaticPattern = void 0; | ||
const path = require("path"); | ||
const globParent = require("glob-parent"); | ||
const micromatch = require("micromatch"); | ||
const picomatch = require("picomatch"); | ||
const GLOBSTAR = '**'; | ||
@@ -71,2 +70,28 @@ const ESCAPE_SYMBOL = '\\'; | ||
exports.getPositivePatterns = getPositivePatterns; | ||
/** | ||
* Returns patterns that can be applied inside the current directory. | ||
* | ||
* @example | ||
* // ['./*', '*', 'a/*'] | ||
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*']) | ||
*/ | ||
function getPatternsInsideCurrentDirectory(patterns) { | ||
return patterns.filter((pattern) => !isPatternRelatedToParentDirectory(pattern)); | ||
} | ||
exports.getPatternsInsideCurrentDirectory = getPatternsInsideCurrentDirectory; | ||
/** | ||
* Returns patterns to be expanded relative to (outside) the current directory. | ||
* | ||
* @example | ||
* // ['../*', './../*'] | ||
* getPatternsInsideCurrentDirectory(['./*', '*', 'a/*', '../*', './../*']) | ||
*/ | ||
function getPatternsOutsideCurrentDirectory(patterns) { | ||
return patterns.filter(isPatternRelatedToParentDirectory); | ||
} | ||
exports.getPatternsOutsideCurrentDirectory = getPatternsOutsideCurrentDirectory; | ||
function isPatternRelatedToParentDirectory(pattern) { | ||
return pattern.startsWith('..') || pattern.startsWith('./..'); | ||
} | ||
exports.isPatternRelatedToParentDirectory = isPatternRelatedToParentDirectory; | ||
function getBaseDirectory(pattern) { | ||
@@ -103,3 +128,3 @@ return globParent(pattern, { flipBackslashes: false }); | ||
function getPatternParts(pattern, options) { | ||
let { parts } = picomatch.scan(pattern, Object.assign(Object.assign({}, options), { parts: true })); | ||
let { parts } = micromatch.scan(pattern, Object.assign(Object.assign({}, options), { parts: true })); | ||
/** | ||
@@ -106,0 +131,0 @@ * The scan method returns an empty array in some cases. |
{ | ||
"name": "fast-glob", | ||
"version": "3.2.5", | ||
"version": "3.2.6", | ||
"description": "It's a very fast and efficient glob library for Node.js", | ||
@@ -16,2 +16,8 @@ "license": "MIT", | ||
"typings": "out/index.d.ts", | ||
"files": [ | ||
"out", | ||
"!out/{benchmark,tests}", | ||
"!out/**/*.map", | ||
"!out/**/*.spec.*" | ||
], | ||
"keywords": [ | ||
@@ -43,2 +49,3 @@ "glob", | ||
"fast-glob": "^3.0.4", | ||
"fdir": "^5.1.0", | ||
"glob": "^7.1.4", | ||
@@ -57,6 +64,5 @@ "is-ci": "^2.0.0", | ||
"@nodelib/fs.walk": "^1.2.3", | ||
"glob-parent": "^5.1.0", | ||
"glob-parent": "^5.1.2", | ||
"merge2": "^1.3.0", | ||
"micromatch": "^4.0.2", | ||
"picomatch": "^2.2.1" | ||
"micromatch": "^4.0.4" | ||
}, | ||
@@ -63,0 +69,0 @@ "scripts": { |
@@ -336,4 +336,6 @@ # fast-glob | ||
Indicates whether to traverse descendants of symbolic link directories. | ||
Indicates whether to traverse descendants of symbolic link directories when expanding `**` patterns. | ||
> :book: Note that this option does not affect the base directory of the pattern. For example, if `./a` is a symlink to directory `./b` and you specified `['./a**', './b/**']` patterns, then directory `./a` will still be read. | ||
> :book: If the [`stats`](#stats) option is specified, the information about the symbolic link (`fs.lstat`) will be replaced with information about the entry (`fs.stat`) behind it. | ||
@@ -340,0 +342,0 @@ |
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
88062
5
1490
796
29
- Removedpicomatch@^2.2.1
Updatedglob-parent@^5.1.2
Updatedmicromatch@^4.0.4