From 36e83c8a78a21f5c8209ef16be040cd0e6fac40e Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Mon, 7 Oct 2019 09:06:02 +0300 Subject: [PATCH 1/5] build(package): require `fast-glob@3.1.0` version or above --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10ffaf4..306cab8 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@types/glob": "^7.1.1", "array-union": "^2.1.0", "dir-glob": "^3.0.1", - "fast-glob": "^3.0.3", + "fast-glob": "^3.1.0", "glob": "^7.1.3", "ignore": "^5.1.1", "merge2": "^1.2.3", From 90eb770e4892dccd8236dc6fbcb822688eebe3a4 Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Mon, 7 Oct 2019 09:06:35 +0300 Subject: [PATCH 2/5] refactor: use `fg.isDynamicPattern` instead of `glob.hasMagic` --- index.d.ts | 9 ++++----- index.js | 3 +-- index.test-d.ts | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index 434931d..3d931d0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,3 @@ -import {IOptions as NodeGlobOptions} from 'glob'; import {Options as FastGlobOptions} from 'fast-glob'; declare namespace globby { @@ -157,17 +156,17 @@ declare const globby: { ): globby.GlobTask[]; /** - Note that the options affect the results. If `noext: true` is set, then `+(a|b)` will not be considered a magic pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`, then that is considered magical, unless `nobrace: true` is set. + Note that the options affect the results. - This function is backed by [`node-glob`](https://github.com/isaacs/node-glob#globhasmagicpattern-options). + This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options). @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). - @param options - See the [`node-glob` options](https://github.com/isaacs/node-glob#globhasmagicpattern-options). + @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3). @returns Whether there are any special glob characters in the `patterns`. */ hasMagic( patterns: string | readonly string[], - options?: NodeGlobOptions + options?: FastGlobOptions ): boolean; readonly gitignore: Gitignore; diff --git a/index.js b/index.js index 764441c..3504057 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,6 @@ const fs = require('fs'); const arrayUnion = require('array-union'); const merge2 = require('merge2'); -const glob = require('glob'); const fastGlob = require('fast-glob'); const dirGlob = require('dir-glob'); const gitignore = require('./gitignore'); @@ -173,6 +172,6 @@ module.exports.generateGlobTasks = generateGlobTasks; module.exports.hasMagic = (patterns, options) => [] .concat(patterns) - .some(pattern => glob.hasMagic(pattern, options)); + .some(pattern => fastGlob.isDynamicPattern(pattern, options)); module.exports.gitignore = gitignore; diff --git a/index.test-d.ts b/index.test-d.ts index e71dff2..414ce84 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -95,7 +95,7 @@ expectType(generateGlobTasks('*.tmp', {ignore: ['**/b.tmp']})); // HasMagic expectType(hasMagic('**')); expectType(hasMagic(['**', 'path1', 'path2'])); -expectType(hasMagic(['**', 'path1', 'path2'], {noext: true})); +expectType(hasMagic(['**', 'path1', 'path2'], {extglob: false})); // Gitignore expectType>(gitignore()); From 8cf7984c354b8c2ea4102fc0f7696dcb076293bc Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Mon, 7 Oct 2019 09:07:09 +0300 Subject: [PATCH 3/5] docs(README): update documentation for `hasMagic` method --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 22440df..fac1d0e 100644 --- a/readme.md +++ b/readme.md @@ -123,9 +123,9 @@ Note that you should avoid running the same tasks multiple times as they contain Returns a `boolean` of whether there are any special glob characters in the `patterns`. -Note that the options affect the results. If `noext: true` is set, then `+(a|b)` will not be considered a magic pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`, then that is considered magical, unless `nobrace: true` is set. +Note that the options affect the results. -This function is backed by [`node-glob`](https://github.com/isaacs/node-glob#globhasmagicpattern-options) +This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options). ### globby.gitignore(options?) From 212aebb86331a815f876c5fc7fe1e283fbee7d16 Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Mon, 7 Oct 2019 09:07:31 +0300 Subject: [PATCH 4/5] build(package): drop `glob` and `@types/glob` dependencies --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index 306cab8..61c6f90 100644 --- a/package.json +++ b/package.json @@ -56,11 +56,9 @@ "git" ], "dependencies": { - "@types/glob": "^7.1.1", "array-union": "^2.1.0", "dir-glob": "^3.0.1", "fast-glob": "^3.1.0", - "glob": "^7.1.3", "ignore": "^5.1.1", "merge2": "^1.2.3", "slash": "^3.0.0" From 840218a7db76d7294f28575b3cc8a70f6261fb0d Mon Sep 17 00:00:00 2001 From: mrmlnc Date: Mon, 7 Oct 2019 09:09:39 +0300 Subject: [PATCH 5/5] docs: update link to fast-glob options --- index.d.ts | 8 ++++---- readme.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3d931d0..ba26401 100644 --- a/index.d.ts +++ b/index.d.ts @@ -84,7 +84,7 @@ declare const globby: { 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-1) in addition to the ones in this package. + @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 @@ -110,7 +110,7 @@ declare const globby: { 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-1) in addition to the ones in this package. + @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( @@ -124,7 +124,7 @@ declare const globby: { 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-1) in addition to the ones in this package. + @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. @example @@ -147,7 +147,7 @@ declare const globby: { 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. @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-1) in addition to the ones in this package. + @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package. @returns An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages. */ generateGlobTasks( diff --git a/readme.md b/readme.md index fac1d0e..b5b3f8c 100644 --- a/readme.md +++ b/readme.md @@ -59,7 +59,7 @@ See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage). Type: `object` -See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-1) in addition to the ones below. +See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones below. ##### expandDirectories