Comparing version 2.0.2 to 2.0.3
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function prepare(options) { | ||
return Object.assign({ | ||
var opts = Object.assign({ | ||
cwd: process.cwd(), | ||
@@ -23,3 +23,7 @@ deep: true, | ||
}, options); | ||
if (opts.onlyDirectories) { | ||
opts.onlyFiles = false; | ||
} | ||
return opts; | ||
} | ||
exports.prepare = prepare; |
@@ -93,3 +93,6 @@ "use strict"; | ||
var ignore = options.ignore; | ||
var negative = patternUtils.getNegativePatterns(patterns).map(patternUtils.convertToPositivePattern).concat(ignore); | ||
var negative = patternUtils.getNegativePatterns(patterns) | ||
.map(patternUtils.convertToPositivePattern) | ||
.concat(ignore) | ||
.map(patternUtils.trimTrailingSlashGlobStar); | ||
var positiveGroup = groupPatternsByParentDirectory(positive); | ||
@@ -96,0 +99,0 @@ var negativeGroup = groupPatternsByParentDirectory(negative); |
@@ -37,2 +37,10 @@ /// <reference types="micromatch" /> | ||
/** | ||
* Return true if provided pattern ends with slash and globstar. | ||
*/ | ||
export declare function endsWithSlashGlobStar(pattern: Pattern): boolean; | ||
/** | ||
* Trim trailing globstar if provided pattern ends with slash and globstar. | ||
*/ | ||
export declare function trimTrailingSlashGlobStar(pattern: Pattern): Pattern; | ||
/** | ||
* Return naive depth of provided pattern. | ||
@@ -39,0 +47,0 @@ */ |
@@ -15,2 +15,3 @@ "use strict"; | ||
var micromatch = require("micromatch"); | ||
var GLOBSTAR = '**'; | ||
/** | ||
@@ -69,6 +70,20 @@ * Returns negative pattern as positive pattern. | ||
function hasGlobStar(pattern) { | ||
return pattern.indexOf('**') !== -1; | ||
return pattern.indexOf(GLOBSTAR) !== -1; | ||
} | ||
exports.hasGlobStar = hasGlobStar; | ||
/** | ||
* Return true if provided pattern ends with slash and globstar. | ||
*/ | ||
function endsWithSlashGlobStar(pattern) { | ||
return pattern.endsWith('/' + GLOBSTAR); | ||
} | ||
exports.endsWithSlashGlobStar = endsWithSlashGlobStar; | ||
/** | ||
* Trim trailing globstar if provided pattern ends with slash and globstar. | ||
*/ | ||
function trimTrailingSlashGlobStar(pattern) { | ||
return endsWithSlashGlobStar(pattern) ? pattern.slice(0, -3) : pattern; | ||
} | ||
exports.trimTrailingSlashGlobStar = trimTrailingSlashGlobStar; | ||
/** | ||
* Return naive depth of provided pattern. | ||
@@ -75,0 +90,0 @@ */ |
{ | ||
"name": "fast-glob", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Is a faster `node-glob` alternative", | ||
@@ -26,3 +26,3 @@ "license": "MIT", | ||
"@types/execa": "^0.8.1", | ||
"@types/glob": "^5.0.34", | ||
"@types/glob": "^5.0.35", | ||
"@types/glob-parent": "^3.1.0", | ||
@@ -34,4 +34,4 @@ "@types/glob-stream": "^6.1.0", | ||
"@types/minimist": "^1.2.0", | ||
"@types/mocha": "^2.2.46", | ||
"@types/node": "^9.3.0", | ||
"@types/mocha": "^2.2.48", | ||
"@types/node": "^9.4.0", | ||
"@types/readdir-enhanced": "^2.2.0", | ||
@@ -41,12 +41,12 @@ "@types/rimraf": "2.0.2", | ||
"compute-stdev": "^1.0.0", | ||
"execa": "^0.8.0", | ||
"fast-glob": "^2.0.0", | ||
"execa": "^0.9.0", | ||
"fast-glob": "^2.0.1", | ||
"glob-stream": "^6.1.0", | ||
"globby": "^7.1.1", | ||
"minimist": "^1.2.0", | ||
"mocha": "^4.1.0", | ||
"mocha": "^5.0.0", | ||
"rimraf": "^2.6.2", | ||
"tslint": "^5.8.0", | ||
"tslint": "^5.9.1", | ||
"tslint-config-mrmlnc": "^1.0.0", | ||
"typescript": "^2.6.2" | ||
"typescript": "^2.7.1" | ||
}, | ||
@@ -53,0 +53,0 @@ "dependencies": { |
@@ -12,3 +12,3 @@ # :rocket: fast-glob | ||
* :beginner: User-friendly, since it supports multiple and negated patterns (`['*', '!*.md']`). | ||
* :vertical_traffic_light: Rational, because it doesn't read excluded directories (`!**/node_modules`). | ||
* :vertical_traffic_light: Rational, because it doesn't read excluded directories (`!**/node_modules/**`). | ||
* :gear: Universal, because it supports Synchronous, Promise and Stream API. | ||
@@ -76,2 +76,4 @@ * :money_with_wings: Economy, because it provides `fs.Stats` for matched path if you wanted. | ||
This package does not respect the order of patterns. First, all the negative patterns are applied, and only then the positive patterns. | ||
#### options | ||
@@ -239,3 +241,3 @@ | ||
You can use a negative pattern like this: `!**/node_modules`. Also you can use `ignore` option. Just look at the example below. | ||
You can use a negative pattern like this: `!**/node_modules` or `!**/node_modules/**`. Also you can use `ignore` option. Just look at the example below. | ||
@@ -247,19 +249,13 @@ * **first/** | ||
If you don't want to read the `second` directory, you must write the following pattern: `!**/second`. | ||
If you don't want to read the `second` directory, you must write the following pattern: `!**/second` or `!**/second/**`. | ||
```js | ||
fg.sync(['**/*.md', '!**/second']); // ['first/file.txt'] | ||
fg.sync(['**/*.md'], { ignore: '**/second' }); // ['first/file.txt'] | ||
fg.sync(['**/*.md'], { ignore: '**/second/**' }); // ['first/file.txt'] | ||
``` | ||
> :warning: When you write `!**/second/**` it means that the directory will be **read**, but all the entries will not be included in the results. | ||
> :warning: When you write `!**/second/**/*` it means that the directory will be **read**, but all the entries will not be included in the results. | ||
You have to understand that if you write the pattern to exclude directories, then the directory will not be read under any circumstances. But… you can specify a more meaningful pattern, which will be launched in parallel with the first. | ||
You have to understand that if you write the pattern to exclude directories, then the directory will not be read under any circumstances. | ||
```js | ||
fg.sync(['**/*.txt', '!**/second', 'first/second/**/*.txt']); // ['first/file.txt', 'first/second/file.txt'] | ||
``` | ||
However, be aware that it may not work as you expect in case where inside the `second` directory there is a directory matching to the pattern for exluding directory. Yes, sounds complicated. Simpler: the `second` directory inside the `second` directory. | ||
## Compatible with `node-glob`? | ||
@@ -266,0 +262,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
50639
1114
35
308