diff --git a/README.md b/README.md index 4023d50e..938c35fa 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,7 @@ Enable a [case-sensitive](https://en.wikipedia.org/wiki/Case_sensitivity) mode f * Case-sensitive for `test/file.*` pattern: `test/file.md` * Case-insensitive for `test/file.*` pattern: `test/file.md`, `test/File.md` -#### matchBase +#### baseNameMatch * Type: `boolean` * Default: `false` @@ -404,7 +404,7 @@ Not fully, because `fast-glob` does not implement all options of `node-glob`. Se | `noglobstar` | [`globstar`](#globstar) | | `noext` | [`extglob`](#extglob) | | `nocase` | [`caseSensitiveMatch`](#caseSensitiveMatch) | -| `matchBase` | [`matchbase`](#matchbase) | +| `matchBase` | [`baseNameMatch`](#baseNameMatch) | | `nodir` | [`onlyFiles`](#onlyfiles) | | `ignore` | [`ignore`](#ignore) | | `follow` | [`followSymbolicLinks`](#followSymbolicLinks) | diff --git a/src/providers/provider.ts b/src/providers/provider.ts index 255b5b57..ede278dc 100644 --- a/src/providers/provider.ts +++ b/src/providers/provider.ts @@ -42,7 +42,7 @@ export default abstract class Provider { protected _getMicromatchOptions(): MicromatchOptions { return { dot: this._settings.dot, - matchBase: this._settings.matchBase, + matchBase: this._settings.baseNameMatch, nobrace: !this._settings.braceExpansion, nocase: !this._settings.caseSensitiveMatch, noext: !this._settings.extglob, diff --git a/src/settings.spec.ts b/src/settings.spec.ts index 0850eb95..a77a7091 100644 --- a/src/settings.spec.ts +++ b/src/settings.spec.ts @@ -6,27 +6,27 @@ describe('Settings', () => { it('should return instance with default values', () => { const settings = new Settings(); - assert.strictEqual(settings.concurrency, Infinity); - assert.strictEqual(settings.cwd, process.cwd()); - assert.ok(settings.deep); + assert.deepStrictEqual(settings.fs, DEFAULT_FILE_SYSTEM_ADAPTER); assert.deepStrictEqual(settings.ignore, []); + assert.ok(!settings.absolute); + assert.ok(!settings.baseNameMatch); assert.ok(!settings.dot); + assert.ok(!settings.markDirectories); assert.ok(!settings.objectMode); - assert.ok(!settings.stats); - assert.ok(settings.onlyFiles); assert.ok(!settings.onlyDirectories); - assert.ok(settings.followSymbolicLinks); + assert.ok(!settings.stats); + assert.ok(!settings.suppressErrors); assert.ok(!settings.throwErrorOnBrokenSymbolicLink); - assert.ok(settings.unique); - assert.ok(!settings.markDirectories); - assert.ok(!settings.absolute); assert.ok(settings.braceExpansion); - assert.ok(settings.globstar); - assert.ok(settings.extglob); assert.ok(settings.caseSensitiveMatch); - assert.ok(!settings.matchBase); - assert.ok(!settings.suppressErrors); - assert.deepStrictEqual(settings.fs, DEFAULT_FILE_SYSTEM_ADAPTER); + assert.ok(settings.deep); + assert.ok(settings.extglob); + assert.ok(settings.followSymbolicLinks); + assert.ok(settings.globstar); + assert.ok(settings.onlyFiles); + assert.ok(settings.unique); + assert.strictEqual(settings.concurrency, Infinity); + assert.strictEqual(settings.cwd, process.cwd()); }); it('should return instance with custom values', () => { diff --git a/src/settings.ts b/src/settings.ts index e9b5275e..f9166b99 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -91,7 +91,7 @@ export interface Options { * Allow glob patterns without slashes to match a file path based on its basename. * For example, `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. */ - matchBase?: boolean; + baseNameMatch?: boolean; /** * Suppress any errors from reader. * Can be useful when the directory has entries with a special level of access. @@ -105,6 +105,7 @@ export interface Options { export default class Settings { public readonly absolute: boolean = this._getValue(this._options.absolute, false); + public readonly baseNameMatch: boolean = this._getValue(this._options.baseNameMatch, false); public readonly braceExpansion: boolean = this._getValue(this._options.braceExpansion, true); public readonly caseSensitiveMatch: boolean = this._getValue(this._options.caseSensitiveMatch, true); public readonly concurrency: number = this._getValue(this._options.concurrency, Infinity); @@ -117,7 +118,6 @@ export default class Settings { public readonly globstar: boolean = this._getValue(this._options.globstar, true); public readonly ignore: Pattern[] = this._getValue(this._options.ignore, [] as Pattern[]); public readonly markDirectories: boolean = this._getValue(this._options.markDirectories, false); - public readonly matchBase: boolean = this._getValue(this._options.matchBase, false); public readonly objectMode: boolean = this._getValue(this._options.objectMode, false); public readonly onlyDirectories: boolean = this._getValue(this._options.onlyDirectories, false); public readonly onlyFiles: boolean = this._getValue(this._options.onlyFiles, true); diff --git a/src/tests/smoke/match-base.smoke.ts b/src/tests/smoke/match-base.smoke.ts index 796f66c5..0cd99064 100644 --- a/src/tests/smoke/match-base.smoke.ts +++ b/src/tests/smoke/match-base.smoke.ts @@ -7,6 +7,6 @@ smoke.suite('Smoke → MatchBase', [ pattern: '*.md', cwd: 'fixtures', globOptions: { matchBase: true }, - fgOptions: { matchBase: true } + fgOptions: { baseNameMatch: true } } ]);