Comparing version
'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 [](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`. |
12359
0.62%6
-14.29%180
0.56%7
16.67%1
-50%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added