Comparing version 7.1.1 to 8.0.0
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
const fastGlob = require('fast-glob'); | ||
const gitIgnore = require('ignore'); | ||
@@ -9,3 +9,10 @@ const pify = require('pify'); | ||
const globP = pify(glob); | ||
const DEFAULT_IGNORE = [ | ||
'**/node_modules/**', | ||
'**/bower_components/**', | ||
'**/flow-typed/**', | ||
'**/coverage/**', | ||
'**/.git' | ||
]; | ||
const readFileP = pify(fs.readFile); | ||
@@ -76,3 +83,3 @@ | ||
return globP('**/.gitignore', {ignore: opts.ignore, cwd: opts.cwd}) | ||
return fastGlob('**/.gitignore', {ignore: DEFAULT_IGNORE.concat(opts.ignore), cwd: opts.cwd}) | ||
.then(paths => Promise.all(paths.map(file => getFile(file, opts.cwd)))) | ||
@@ -86,3 +93,3 @@ .then(files => reduceIgnore(files)) | ||
const paths = glob.sync('**/.gitignore', {ignore: opts.ignore, cwd: opts.cwd}); | ||
const paths = fastGlob.sync('**/.gitignore', {ignore: DEFAULT_IGNORE.concat(opts.ignore), cwd: opts.cwd}); | ||
const files = paths.map(file => getFileSync(file, opts.cwd)); | ||
@@ -89,0 +96,0 @@ const ignores = reduceIgnore(files); |
11
index.js
'use strict'; | ||
const arrayUnion = require('array-union'); | ||
const glob = require('glob'); | ||
const pify = require('pify'); | ||
const fastGlob = require('fast-glob'); | ||
const dirGlob = require('dir-glob'); | ||
const gitignore = require('./gitignore'); | ||
const globP = pify(glob); | ||
const DEFAULT_FILTER = () => false; | ||
@@ -26,6 +25,2 @@ | ||
taskOpts = Object.assign({ | ||
cache: Object.create(null), | ||
statCache: Object.create(null), | ||
realpathCache: Object.create(null), | ||
symlinks: Object.create(null), | ||
ignore: [], | ||
@@ -98,3 +93,3 @@ expandDirectories: true, | ||
return getTasks | ||
.then(tasks => Promise.all(tasks.map(task => globP(task.pattern, task.opts)))) | ||
.then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.opts)))) | ||
.then(paths => arrayUnion.apply(null, paths)) | ||
@@ -125,3 +120,3 @@ .then(paths => paths.filter(p => !filter(p))); | ||
return tasks.reduce( | ||
(matches, task) => arrayUnion(matches, glob.sync(task.pattern, task.opts)), | ||
(matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.opts)), | ||
[] | ||
@@ -128,0 +123,0 @@ ).filter(p => !filter(p)); |
{ | ||
"name": "globby", | ||
"version": "7.1.1", | ||
"version": "8.0.0", | ||
"description": "Extends `glob` with support for multiple patterns and exposes a Promise API", | ||
@@ -60,2 +60,3 @@ "license": "MIT", | ||
"dir-glob": "^2.0.0", | ||
"fast-glob": "^2.0.2", | ||
"glob": "^7.1.2", | ||
@@ -68,3 +69,2 @@ "ignore": "^3.3.5", | ||
"ava": "*", | ||
"fast-glob": "^1.0.1", | ||
"glob-stream": "^6.1.0", | ||
@@ -71,0 +71,0 @@ "globby": "sindresorhus/globby#master", |
@@ -5,3 +5,3 @@ # globby [![Build Status](https://travis-ci.org/sindresorhus/globby.svg?branch=master)](https://travis-ci.org/sindresorhus/globby) | ||
Based on [`glob`](https://github.com/isaacs/node-glob), but adds a bunch of useful features and a nicer API. | ||
Based on [`fast-glob`](https://github.com/mrmlnc/fast-glob), but adds a bunch of useful features and a nicer API. | ||
@@ -61,6 +61,4 @@ | ||
See the [`node-glob` options](https://github.com/isaacs/node-glob#options) in addition to the ones below. | ||
See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options) in addition to the ones below. | ||
One difference is that `nodir` is `true` by default here. | ||
##### expandDirectories | ||
@@ -102,3 +100,3 @@ | ||
Returns an `Array<Object>` in the format `{pattern: string, opts: Object}`, which can be passed as arguments to [`node-glob`](https://github.com/isaacs/node-glob). This is useful for other globbing-related packages. | ||
Returns an `Array<Object>` in the format `{pattern: string, opts: Object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages. | ||
@@ -113,5 +111,7 @@ Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration. | ||
This function is backed by [`node-glob`](https://github.com/isaacs/node-glob#globhasmagicpattern-options) | ||
### globby.gitignore([options]) | ||
Returns a `Promise<(path: string) => boolean>` indicating wether a given path is ignored via a `.gitignore` file. | ||
Returns a `Promise<(path: string) => boolean>` indicating whether a given path is ignored via a `.gitignore` file. | ||
@@ -132,3 +132,3 @@ Takes `cwd?: string` and `ignore?: string[]` as options. `.gitignore` files matched by the ignore config are not | ||
Returns a `(path: string) => boolean` indicating wether a given path is ignored via a `.gitignore` file. | ||
Returns a `(path: string) => boolean` indicating whether a given path is ignored via a `.gitignore` file. | ||
@@ -135,0 +135,0 @@ Takes the same options as `globby.gitignore`. |
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
12359
6
180
7
+ Addedfast-glob@^2.0.2
+ Added@mrmlnc/readdir-enhanced@2.2.1(transitive)
+ Added@nodelib/fs.stat@1.1.3(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-unique@0.3.2(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbraces@2.3.2(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedcall-me-maybe@1.0.2(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addedexpand-brackets@2.1.4(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@2.0.4(transitive)
+ Addedfast-glob@2.2.7(transitive)
+ Addedfill-range@4.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedglob-parent@3.1.0(transitive)
+ Addedglob-to-regexp@0.3.0(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@3.1.04.0.3(transitive)
+ Addedis-number@3.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedkind-of@3.2.24.0.06.0.3(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@3.1.10(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpath-dirname@1.0.2(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)