Comparing version 11.0.1 to 11.0.2
@@ -37,3 +37,4 @@ 'use strict'; | ||
const reduceIgnore = files => { | ||
return files.reduce((ignores, file) => { | ||
const ignores = gitIgnore(); | ||
for (const file of files) { | ||
ignores.add(parseGitIgnore(file.content, { | ||
@@ -43,4 +44,5 @@ cwd: file.cwd, | ||
})); | ||
return ignores; | ||
}, gitIgnore()); | ||
} | ||
return ignores; | ||
}; | ||
@@ -62,3 +64,3 @@ | ||
const getIsIgnoredPredecate = (ignores, cwd) => { | ||
return p => ignores.ignores(slash(path.relative(cwd, ensureAbsolutePathForCwd(cwd, p)))); | ||
return p => ignores.ignores(slash(path.relative(cwd, ensureAbsolutePathForCwd(cwd, p.path || p)))); | ||
}; | ||
@@ -65,0 +67,0 @@ |
@@ -46,3 +46,3 @@ import {Options as FastGlobOptions} from 'fast-glob'; | ||
readonly pattern: string; | ||
readonly options: globby.GlobbyOptions; | ||
readonly options: GlobbyOptions; | ||
} | ||
@@ -60,2 +60,7 @@ | ||
/** | ||
@returns A filter function indicating whether a given path is ignored via a `.gitignore` file. | ||
*/ | ||
sync: (options?: globby.GitignoreOptions) => globby.FilterFunction; | ||
/** | ||
`.gitignore` files matched by the ignore config are not used for the resulting filter function. | ||
@@ -76,7 +81,2 @@ | ||
(options?: globby.GitignoreOptions): Promise<globby.FilterFunction>; | ||
/** | ||
@returns A filter function indicating whether a given path is ignored via a `.gitignore` file. | ||
*/ | ||
sync(options?: globby.GitignoreOptions): globby.FilterFunction; | ||
} | ||
@@ -93,19 +93,7 @@ | ||
@returns The matching paths. | ||
@example | ||
``` | ||
import globby = require('globby'); | ||
(async () => { | ||
const paths = await globby(['*', '!cake']); | ||
console.log(paths); | ||
//=> ['unicorn', 'rainbow'] | ||
})(); | ||
``` | ||
*/ | ||
( | ||
sync: ( | ||
patterns: string | readonly string[], | ||
options?: globby.GlobbyOptions | ||
): Promise<string[]>; | ||
) => string[]; | ||
@@ -119,16 +107,2 @@ /** | ||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package. | ||
@returns The matching paths. | ||
*/ | ||
sync( | ||
patterns: string | readonly string[], | ||
options?: globby.GlobbyOptions | ||
): string[]; | ||
/** | ||
Find files and directories using glob patterns. | ||
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`. | ||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). | ||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package. | ||
@returns The stream of matching paths. | ||
@@ -147,6 +121,6 @@ | ||
*/ | ||
stream( | ||
stream: ( | ||
patterns: string | readonly string[], | ||
options?: globby.GlobbyOptions | ||
): NodeJS.ReadableStream; | ||
) => NodeJS.ReadableStream; | ||
@@ -160,6 +134,6 @@ /** | ||
*/ | ||
generateGlobTasks( | ||
generateGlobTasks: ( | ||
patterns: string | readonly string[], | ||
options?: globby.GlobbyOptions | ||
): globby.GlobTask[]; | ||
) => globby.GlobTask[]; | ||
@@ -175,10 +149,36 @@ /** | ||
*/ | ||
hasMagic( | ||
hasMagic: ( | ||
patterns: string | readonly string[], | ||
options?: FastGlobOptions | ||
): boolean; | ||
) => boolean; | ||
readonly gitignore: Gitignore; | ||
/** | ||
Find files and directories using glob patterns. | ||
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`. | ||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). | ||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package. | ||
@returns The matching paths. | ||
@example | ||
``` | ||
import globby = require('globby'); | ||
(async () => { | ||
const paths = await globby(['*', '!cake']); | ||
console.log(paths); | ||
//=> ['unicorn', 'rainbow'] | ||
})(); | ||
``` | ||
*/ | ||
( | ||
patterns: string | readonly string[], | ||
options?: globby.GlobbyOptions | ||
): Promise<string[]>; | ||
}; | ||
export = globby; |
28
index.js
@@ -28,3 +28,3 @@ 'use strict'; | ||
stat = fs.statSync(options.cwd); | ||
} catch (_) { | ||
} catch { | ||
return; | ||
@@ -60,3 +60,3 @@ } | ||
.slice(index) | ||
.filter(isNegative) | ||
.filter(pattern => isNegative(pattern)) | ||
.map(pattern => pattern.slice(1)); | ||
@@ -143,13 +143,16 @@ | ||
const tasks = globTasks.reduce((tasks, task) => { | ||
const tasks = []; | ||
for (const task of globTasks) { | ||
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task)); | ||
return tasks.concat(newTask); | ||
}, []); | ||
tasks.push(...newTask); | ||
} | ||
const filter = getFilterSync(options); | ||
return tasks.reduce( | ||
(matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.options)), | ||
[] | ||
).filter(path_ => !filter(path_)); | ||
let matches = []; | ||
for (const task of tasks) { | ||
matches = arrayUnion(matches, fastGlob.sync(task.pattern, task.options)); | ||
} | ||
return matches.filter(path_ => !filter(path_)); | ||
}; | ||
@@ -160,6 +163,7 @@ | ||
const tasks = globTasks.reduce((tasks, task) => { | ||
const tasks = []; | ||
for (const task of globTasks) { | ||
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task)); | ||
return tasks.concat(newTask); | ||
}, []); | ||
tasks.push(...newTask); | ||
} | ||
@@ -166,0 +170,0 @@ const filter = getFilterSync(options); |
{ | ||
"name": "globby", | ||
"version": "11.0.1", | ||
"version": "11.0.2", | ||
"description": "User-friendly glob matching", | ||
@@ -11,3 +11,3 @@ "license": "MIT", | ||
"name": "Sindre Sorhus", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
@@ -69,10 +69,10 @@ "engines": { | ||
"devDependencies": { | ||
"ava": "^2.1.0", | ||
"get-stream": "^5.1.0", | ||
"ava": "^3.13.0", | ||
"get-stream": "^6.0.0", | ||
"glob-stream": "^6.1.0", | ||
"globby": "sindresorhus/globby#master", | ||
"matcha": "^0.7.0", | ||
"rimraf": "^3.0.0", | ||
"tsd": "^0.11.0", | ||
"xo": "^0.25.3" | ||
"rimraf": "^3.0.2", | ||
"tsd": "^0.13.1", | ||
"xo": "^0.33.1" | ||
}, | ||
@@ -79,0 +79,0 @@ "xo": { |
@@ -1,2 +0,2 @@ | ||
# globby [![Build Status](https://travis-ci.org/sindresorhus/globby.svg?branch=master)](https://travis-ci.org/sindresorhus/globby) | ||
# globby | ||
@@ -3,0 +3,0 @@ > User-friendly glob matching |
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
412
21453