From 057d5b231018e2aaf64dd4f27b621257d59cadfc Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 23 May 2024 23:00:09 -0700 Subject: [PATCH] update prettier, format everything --- .prettierignore | 20 +++++---- README.md | 33 ++++++++------- examples/g.js | 2 +- package-lock.json | 12 +++--- package.json | 5 ++- src/bin.mts | 44 ++++++++++---------- src/glob.ts | 69 ++++++++++++++---------------- src/has-magic.ts | 2 +- src/ignore.ts | 14 ++++--- src/index.ts | 60 +++++++++++++------------- src/pattern.ts | 34 ++++++++------- src/processor.ts | 15 ++++--- src/walker.ts | 74 ++++++++++++++++----------------- test/00-setup.ts | 26 ++++++------ test/absolute.ts | 4 +- test/bash-comparison.ts | 4 +- test/bin.ts | 6 +-- test/broken-symlink.ts | 2 +- test/custom-fs.ts | 4 +- test/custom-ignore.ts | 4 +- test/cwd-noent.ts | 2 +- test/cwd-test.ts | 6 +-- test/dot-relative.ts | 8 ++-- test/escape.ts | 4 +- test/follow.ts | 4 +- test/has-magic.ts | 8 ++-- test/ignore.ts | 11 +++-- test/include-child-matches.ts | 20 +++++---- test/match-base.ts | 30 ++++++------- test/max-depth.ts | 20 ++++----- test/memfs.ts | 4 +- test/nodir.ts | 6 +-- test/pattern.ts | 6 +-- test/platform.ts | 8 ++-- test/progra-tilde.ts | 4 +- test/realpath.ts | 12 +++--- test/signal.ts | 2 +- test/stat.ts | 2 +- test/stream.ts | 8 ++-- test/windows-paths-fs.ts | 10 ++--- test/windows-paths-no-escape.ts | 4 +- 41 files changed, 308 insertions(+), 305 deletions(-) diff --git a/.prettierignore b/.prettierignore index fb94be32..1fb4bee3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,11 +1,15 @@ -/node_modules -/example /.github +/.tap +/node_modules +/tap-snapshots + +/scripts/fixtures +/.tap +/.tshy /dist -.env +/docs +/example +/node_modules /tap-snapshots -/.nyc_output -/coverage -/benchmark -/scripts/fixture -/test/fixture +/test/**/fixture +/test/**/fixtures diff --git a/README.md b/README.md index 5bf89e1a..023cd779 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ g3.stream().on('data', path => { 'got a path object', path.fullpath(), path.isDirectory(), - path.readdirSync().map(e => e.name) + path.readdirSync().map(e => e.name), ) }) @@ -606,9 +606,9 @@ share the previously loaded cache. `false`, and a custom `Ignore` is provided that does not have an `add()` method, then it will throw an error. - **Caveat** It *only* ignores matches that would be a descendant + **Caveat** It _only_ ignores matches that would be a descendant of a previous match, and only if that descendant is matched - *after* the ancestor is encountered. Since the file system walk + _after_ the ancestor is encountered. Since the file system walk happens in indeterminate order, it's possible that a match will already be added before its ancestor, if multiple or braced patterns are used. @@ -616,18 +616,21 @@ share the previously loaded cache. For example: ```js - const results = await glob([ - // likely to match first, since it's just a stat - 'a/b/c/d/e/f', - - // this pattern is more complicated! It must to various readdir() - // calls and test the results against a regular expression, and that - // is certainly going to take a little bit longer. - // - // So, later on, it encounters a match at 'a/b/c/d/e', but it's too - // late to ignore a/b/c/d/e/f, because it's already been emitted. - 'a/[bdf]/?/[a-z]/*', - ], { includeChildMatches: false }) + const results = await glob( + [ + // likely to match first, since it's just a stat + 'a/b/c/d/e/f', + + // this pattern is more complicated! It must to various readdir() + // calls and test the results against a regular expression, and that + // is certainly going to take a little bit longer. + // + // So, later on, it encounters a match at 'a/b/c/d/e', but it's too + // late to ignore a/b/c/d/e/f, because it's already been emitted. + 'a/[bdf]/?/[a-z]/*', + ], + { includeChildMatches: false }, + ) ``` It's best to only set this to `false` if you can be reasonably diff --git a/examples/g.js b/examples/g.js index c8537166..9aeb8b3f 100644 --- a/examples/g.js +++ b/examples/g.js @@ -5,7 +5,7 @@ console.log(pattern) var mg = new Glob(pattern, { mark: true, sync: true }, function ( er, - matches + matches, ) { console.log('matches', matches) }) diff --git a/package-lock.json b/package-lock.json index b23943fb..eaa38e0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "@types/node": "^20.11.30", "memfs": "^3.4.13", "mkdirp": "^3.0.1", - "prettier": "^2.8.3", + "prettier": "^3.2.5", "rimraf": "^5.0.7", "sync-content": "^1.0.2", "tap": "^19.0.0", @@ -2980,15 +2980,15 @@ } }, "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" diff --git a/package.json b/package.json index 44d45910..21a9a574 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "presnap": "npm run prepare", "test": "tap", "snap": "tap", - "format": "prettier --write . --loglevel warn", + "format": "prettier --write . --log-level warn", "typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts", "prepublish": "npm run benchclean", "profclean": "rm -f v8.log profile.txt", @@ -55,6 +55,7 @@ "benchclean": "node benchclean.cjs" }, "prettier": { + "experimentalTernaries": true, "semi": false, "printWidth": 75, "tabWidth": 2, @@ -76,7 +77,7 @@ "@types/node": "^20.11.30", "memfs": "^3.4.13", "mkdirp": "^3.0.1", - "prettier": "^2.8.3", + "prettier": "^3.2.5", "rimraf": "^5.0.7", "sync-content": "^1.0.2", "tap": "^19.0.0", diff --git a/src/bin.mts b/src/bin.mts index 31bf6fac..80ae0672 100755 --- a/src/bin.mts +++ b/src/bin.mts @@ -11,13 +11,13 @@ import { globStream } from './index.js' const { version } = JSON.parse( await readFile( fileURLToPath(new URL('../../package.json', import.meta.url)), - 'utf8' + 'utf8', ).catch(() => readFile( fileURLToPath(new URL('../../package.json', import.meta.url)), - 'utf8' - ) - ) + 'utf8', + ), + ), ) as { version: string } /* c8 ignore stop */ @@ -30,7 +30,7 @@ const j = jack({ Expand the positional glob expression arguments into any matching file system paths found. - ` + `, ) .opt({ cmd: { @@ -202,18 +202,18 @@ const j = jack({ available, or 'linux' if not. Setting --platform=win32 on non-Windows systems may cause strange behavior!`, validOptions: [ - 'aix', - 'android', - 'darwin', - 'freebsd', - 'haiku', - 'linux', - 'openbsd', - 'sunos', - 'win32', - 'cygwin', - 'netbsd', - ] + 'aix', + 'android', + 'darwin', + 'freebsd', + 'haiku', + 'linux', + 'openbsd', + 'sunos', + 'win32', + 'cygwin', + 'netbsd', + ], }, }) .optList({ @@ -246,11 +246,11 @@ try { throw 'No patterns provided' if (positionals.length === 0 && values.default) positionals.push(values.default) - const patterns = values.all - ? positionals - : positionals.filter(p => !existsSync(p)) - const matches = values.all - ? [] + const patterns = + values.all ? positionals : positionals.filter(p => !existsSync(p)) + const matches = + values.all ? + [] : positionals.filter(p => existsSync(p)).map(p => join(p)) const stream = globStream(patterns, { absolute: values.absolute, diff --git a/src/glob.ts b/src/glob.ts index 2a379f63..89bd075c 100644 --- a/src/glob.ts +++ b/src/glob.ts @@ -19,11 +19,13 @@ export type GlobParts = Exclude // if no process global, just call it linux. // so we default to case-sensitive, / separators const defaultPlatform: NodeJS.Platform = - typeof process === 'object' && - process && - typeof process.platform === 'string' - ? process.platform - : 'linux' + ( + typeof process === 'object' && + process && + typeof process.platform === 'string' + ) ? + process.platform + : 'linux' /** * A `GlobOptions` object may be provided to any of the exported methods, and @@ -355,21 +357,17 @@ export type GlobOptionsWithFileTypesUnset = GlobOptions & { withFileTypes?: undefined } -export type Result = Opts extends GlobOptionsWithFileTypesTrue - ? Path - : Opts extends GlobOptionsWithFileTypesFalse - ? string - : Opts extends GlobOptionsWithFileTypesUnset - ? string +export type Result = + Opts extends GlobOptionsWithFileTypesTrue ? Path + : Opts extends GlobOptionsWithFileTypesFalse ? string + : Opts extends GlobOptionsWithFileTypesUnset ? string : string | Path export type Results = Result[] -export type FileTypes = Opts extends GlobOptionsWithFileTypesTrue - ? true - : Opts extends GlobOptionsWithFileTypesFalse - ? false - : Opts extends GlobOptionsWithFileTypesUnset - ? false +export type FileTypes = + Opts extends GlobOptionsWithFileTypesTrue ? true + : Opts extends GlobOptionsWithFileTypesFalse ? false + : Opts extends GlobOptionsWithFileTypesUnset ? false : boolean /** @@ -494,13 +492,10 @@ export class Glob implements GlobOptions { } } else { const Scurry = - opts.platform === 'win32' - ? PathScurryWin32 - : opts.platform === 'darwin' - ? PathScurryDarwin - : opts.platform - ? PathScurryPosix - : PathScurry + opts.platform === 'win32' ? PathScurryWin32 + : opts.platform === 'darwin' ? PathScurryDarwin + : opts.platform ? PathScurryPosix + : PathScurry this.scurry = new Scurry(this.cwd, { nocase: opts.nocase, fs: opts.fs, @@ -539,7 +534,7 @@ export class Glob implements GlobOptions { set[1].push(...m.globParts) return set }, - [[], []] + [[], []], ) this.patterns = matchSet.map((set, i) => { const g = globParts[i] @@ -563,9 +558,9 @@ export class Glob implements GlobOptions { ...(await new GlobWalker(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: - this.maxDepth !== Infinity - ? this.maxDepth + this.scurry.cwd.depth() - : Infinity, + this.maxDepth !== Infinity ? + this.maxDepth + this.scurry.cwd.depth() + : Infinity, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches, @@ -582,9 +577,9 @@ export class Glob implements GlobOptions { ...new GlobWalker(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: - this.maxDepth !== Infinity - ? this.maxDepth + this.scurry.cwd.depth() - : Infinity, + this.maxDepth !== Infinity ? + this.maxDepth + this.scurry.cwd.depth() + : Infinity, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches, @@ -600,9 +595,9 @@ export class Glob implements GlobOptions { return new GlobStream(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: - this.maxDepth !== Infinity - ? this.maxDepth + this.scurry.cwd.depth() - : Infinity, + this.maxDepth !== Infinity ? + this.maxDepth + this.scurry.cwd.depth() + : Infinity, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches, @@ -617,9 +612,9 @@ export class Glob implements GlobOptions { return new GlobStream(this.patterns, this.scurry.cwd, { ...this.opts, maxDepth: - this.maxDepth !== Infinity - ? this.maxDepth + this.scurry.cwd.depth() - : Infinity, + this.maxDepth !== Infinity ? + this.maxDepth + this.scurry.cwd.depth() + : Infinity, platform: this.platform, nocase: this.nocase, includeChildMatches: this.includeChildMatches, diff --git a/src/has-magic.ts b/src/has-magic.ts index 748d7c52..3f741362 100644 --- a/src/has-magic.ts +++ b/src/has-magic.ts @@ -14,7 +14,7 @@ import { GlobOptions } from './glob.js' */ export const hasMagic = ( pattern: string | string[], - options: GlobOptions = {} + options: GlobOptions = {}, ): boolean => { if (!Array.isArray(pattern)) { pattern = [pattern] diff --git a/src/ignore.ts b/src/ignore.ts index db83cc24..2e482293 100644 --- a/src/ignore.ts +++ b/src/ignore.ts @@ -15,11 +15,13 @@ export interface IgnoreLike { } const defaultPlatform: NodeJS.Platform = - typeof process === 'object' && - process && - typeof process.platform === 'string' - ? process.platform - : 'linux' + ( + typeof process === 'object' && + process && + typeof process.platform === 'string' + ) ? + process.platform + : 'linux' /** * Class used to process ignored patterns @@ -40,7 +42,7 @@ export class Ignore implements IgnoreLike { noext, noglobstar, platform = defaultPlatform, - }: GlobWalkerOpts + }: GlobWalkerOpts, ) { this.relative = [] this.absolute = [] diff --git a/src/index.ts b/src/index.ts index 10215b4c..df9c7e1a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -37,23 +37,23 @@ export type { MatchStream } from './walker.js' */ export function globStreamSync( pattern: string | string[], - options: GlobOptionsWithFileTypesTrue + options: GlobOptionsWithFileTypesTrue, ): Minipass export function globStreamSync( pattern: string | string[], - options: GlobOptionsWithFileTypesFalse + options: GlobOptionsWithFileTypesFalse, ): Minipass export function globStreamSync( pattern: string | string[], - options: GlobOptionsWithFileTypesUnset + options: GlobOptionsWithFileTypesUnset, ): Minipass export function globStreamSync( pattern: string | string[], - options: GlobOptions + options: GlobOptions, ): Minipass | Minipass export function globStreamSync( pattern: string | string[], - options: GlobOptions = {} + options: GlobOptions = {}, ) { return new Glob(pattern, options).streamSync() } @@ -64,23 +64,23 @@ export function globStreamSync( */ export function globStream( pattern: string | string[], - options: GlobOptionsWithFileTypesFalse + options: GlobOptionsWithFileTypesFalse, ): Minipass export function globStream( pattern: string | string[], - options: GlobOptionsWithFileTypesTrue + options: GlobOptionsWithFileTypesTrue, ): Minipass export function globStream( pattern: string | string[], - options?: GlobOptionsWithFileTypesUnset | undefined + options?: GlobOptionsWithFileTypesUnset | undefined, ): Minipass export function globStream( pattern: string | string[], - options: GlobOptions + options: GlobOptions, ): Minipass | Minipass export function globStream( pattern: string | string[], - options: GlobOptions = {} + options: GlobOptions = {}, ) { return new Glob(pattern, options).stream() } @@ -90,23 +90,23 @@ export function globStream( */ export function globSync( pattern: string | string[], - options: GlobOptionsWithFileTypesFalse + options: GlobOptionsWithFileTypesFalse, ): string[] export function globSync( pattern: string | string[], - options: GlobOptionsWithFileTypesTrue + options: GlobOptionsWithFileTypesTrue, ): Path[] export function globSync( pattern: string | string[], - options?: GlobOptionsWithFileTypesUnset | undefined + options?: GlobOptionsWithFileTypesUnset | undefined, ): string[] export function globSync( pattern: string | string[], - options: GlobOptions + options: GlobOptions, ): Path[] | string[] export function globSync( pattern: string | string[], - options: GlobOptions = {} + options: GlobOptions = {}, ) { return new Glob(pattern, options).walkSync() } @@ -119,23 +119,23 @@ export function globSync( */ async function glob_( pattern: string | string[], - options?: GlobOptionsWithFileTypesUnset | undefined + options?: GlobOptionsWithFileTypesUnset | undefined, ): Promise async function glob_( pattern: string | string[], - options: GlobOptionsWithFileTypesTrue + options: GlobOptionsWithFileTypesTrue, ): Promise async function glob_( pattern: string | string[], - options: GlobOptionsWithFileTypesFalse + options: GlobOptionsWithFileTypesFalse, ): Promise async function glob_( pattern: string | string[], - options: GlobOptions + options: GlobOptions, ): Promise async function glob_( pattern: string | string[], - options: GlobOptions = {} + options: GlobOptions = {}, ) { return new Glob(pattern, options).walk() } @@ -145,23 +145,23 @@ async function glob_( */ export function globIterateSync( pattern: string | string[], - options?: GlobOptionsWithFileTypesUnset | undefined + options?: GlobOptionsWithFileTypesUnset | undefined, ): Generator export function globIterateSync( pattern: string | string[], - options: GlobOptionsWithFileTypesTrue + options: GlobOptionsWithFileTypesTrue, ): Generator export function globIterateSync( pattern: string | string[], - options: GlobOptionsWithFileTypesFalse + options: GlobOptionsWithFileTypesFalse, ): Generator export function globIterateSync( pattern: string | string[], - options: GlobOptions + options: GlobOptions, ): Generator | Generator export function globIterateSync( pattern: string | string[], - options: GlobOptions = {} + options: GlobOptions = {}, ) { return new Glob(pattern, options).iterateSync() } @@ -171,23 +171,23 @@ export function globIterateSync( */ export function globIterate( pattern: string | string[], - options?: GlobOptionsWithFileTypesUnset | undefined + options?: GlobOptionsWithFileTypesUnset | undefined, ): AsyncGenerator export function globIterate( pattern: string | string[], - options: GlobOptionsWithFileTypesTrue + options: GlobOptionsWithFileTypesTrue, ): AsyncGenerator export function globIterate( pattern: string | string[], - options: GlobOptionsWithFileTypesFalse + options: GlobOptionsWithFileTypesFalse, ): AsyncGenerator export function globIterate( pattern: string | string[], - options: GlobOptions + options: GlobOptions, ): AsyncGenerator | AsyncGenerator export function globIterate( pattern: string | string[], - options: GlobOptions = {} + options: GlobOptions = {}, ) { return new Glob(pattern, options).iterate() } diff --git a/src/pattern.ts b/src/pattern.ts index 21ac4ea9..2ea15728 100644 --- a/src/pattern.ts +++ b/src/pattern.ts @@ -10,7 +10,7 @@ export type UNCPatternList = [ p1: '', p2: string, p3: string, - ...rest: MMPattern[] + ...rest: MMPattern[], ] export type DrivePatternList = [p0: string, ...rest: MMPattern[]] export type AbsolutePatternList = [p0: '', ...rest: MMPattern[]] @@ -41,7 +41,7 @@ export class Pattern { patternList: MMPattern[], globList: string[], index: number, - platform: NodeJS.Platform + platform: NodeJS.Platform, ) { if (!isPatternList(patternList)) { throw new TypeError('empty pattern list') @@ -134,11 +134,11 @@ export class Pattern { globString(): string { return (this.#globString = this.#globString || - (this.#index === 0 - ? this.isAbsolute() - ? this.#globList[0] + this.#globList.slice(1).join('/') - : this.#globList.join('/') - : this.#globList.slice(this.#index).join('/'))) + (this.#index === 0 ? + this.isAbsolute() ? + this.#globList[0] + this.#globList.slice(1).join('/') + : this.#globList.join('/') + : this.#globList.slice(this.#index).join('/'))) } /** @@ -158,7 +158,7 @@ export class Pattern { this.#patternList, this.#globList, this.#index + 1, - this.#platform + this.#platform, ) this.#rest.#isAbsolute = this.#isAbsolute this.#rest.#isUNC = this.#isUNC @@ -171,8 +171,8 @@ export class Pattern { */ isUNC(): boolean { const pl = this.#patternList - return this.#isUNC !== undefined - ? this.#isUNC + return this.#isUNC !== undefined ? + this.#isUNC : (this.#isUNC = this.#platform === 'win32' && this.#index === 0 && @@ -194,8 +194,8 @@ export class Pattern { */ isDrive(): boolean { const pl = this.#patternList - return this.#isDrive !== undefined - ? this.#isDrive + return this.#isDrive !== undefined ? + this.#isDrive : (this.#isDrive = this.#platform === 'win32' && this.#index === 0 && @@ -212,8 +212,8 @@ export class Pattern { */ isAbsolute(): boolean { const pl = this.#patternList - return this.#isAbsolute !== undefined - ? this.#isAbsolute + return this.#isAbsolute !== undefined ? + this.#isAbsolute : (this.#isAbsolute = (pl[0] === '' && pl.length > 1) || this.isDrive() || @@ -225,8 +225,10 @@ export class Pattern { */ root(): string { const p = this.#patternList[0] - return typeof p === 'string' && this.isAbsolute() && this.#index === 0 - ? p + return ( + typeof p === 'string' && this.isAbsolute() && this.#index === 0 + ) ? + p : '' } diff --git a/src/processor.ts b/src/processor.ts index 4d2c18ea..4be33e68 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -102,9 +102,8 @@ export class Processor { this.opts = opts this.follow = !!opts.follow this.dot = !!opts.dot - this.hasWalkedCache = hasWalkedCache - ? hasWalkedCache.copy() - : new HasWalkedCache() + this.hasWalkedCache = + hasWalkedCache ? hasWalkedCache.copy() : new HasWalkedCache() } processPatterns(target: Path, patterns: Pattern[]) { @@ -123,9 +122,9 @@ export class Processor { // start absolute patterns at root if (root) { t = t.resolve( - root === '/' && this.opts.root !== undefined - ? this.opts.root - : root + root === '/' && this.opts.root !== undefined ? + this.opts.root + : root, ) const rest = pattern.rest() if (!rest) { @@ -243,7 +242,7 @@ export class Processor { e: Path, pattern: Pattern, rest: Pattern | null, - absolute: boolean + absolute: boolean, ) { if (this.dot || !e.name.startsWith('.')) { if (!pattern.hasMore()) { @@ -293,7 +292,7 @@ export class Processor { e: Path, p: MMRegExp, rest: Pattern | null, - absolute: boolean + absolute: boolean, ) { if (!p.test(e.name)) return if (!rest) { diff --git a/src/walker.ts b/src/walker.ts index d983c6e3..495e0a70 100644 --- a/src/walker.ts +++ b/src/walker.ts @@ -55,20 +55,16 @@ export type GWOFileTypesUnset = GlobWalkerOpts & { withFileTypes?: undefined } -export type Result = O extends GWOFileTypesTrue - ? Path - : O extends GWOFileTypesFalse - ? string - : O extends GWOFileTypesUnset - ? string +export type Result = + O extends GWOFileTypesTrue ? Path + : O extends GWOFileTypesFalse ? string + : O extends GWOFileTypesUnset ? string : Path | string -export type Matches = O extends GWOFileTypesTrue - ? Set - : O extends GWOFileTypesFalse - ? Set - : O extends GWOFileTypesUnset - ? Set +export type Matches = + O extends GWOFileTypesTrue ? Set + : O extends GWOFileTypesFalse ? Set + : O extends GWOFileTypesUnset ? Set : Set export type MatchStream = Minipass< @@ -78,13 +74,11 @@ export type MatchStream = Minipass< const makeIgnore = ( ignore: string | string[] | IgnoreLike, - opts: GlobWalkerOpts + opts: GlobWalkerOpts, ): IgnoreLike => - typeof ignore === 'string' - ? new Ignore([ignore], opts) - : Array.isArray(ignore) - ? new Ignore(ignore, opts) - : ignore + typeof ignore === 'string' ? new Ignore([ignore], opts) + : Array.isArray(ignore) ? new Ignore(ignore, opts) + : ignore /** * basic walking utilities that all the glob walker types use @@ -189,16 +183,18 @@ export abstract class GlobUtil { } matchCheckTest(e: Path | undefined, ifDir: boolean): Path | undefined { - return e && - (this.maxDepth === Infinity || e.depth() <= this.maxDepth) && - (!ifDir || e.canReaddir()) && - (!this.opts.nodir || !e.isDirectory()) && - (!this.opts.nodir || - !this.opts.follow || - !e.isSymbolicLink() || - !e.realpathCached()?.isDirectory()) && - !this.#ignored(e) - ? e + return ( + e && + (this.maxDepth === Infinity || e.depth() <= this.maxDepth) && + (!ifDir || e.canReaddir()) && + (!this.opts.nodir || !e.isDirectory()) && + (!this.opts.nodir || + !this.opts.follow || + !e.isSymbolicLink() || + !e.realpathCached()?.isDirectory()) && + !this.#ignored(e) + ) ? + e : undefined } @@ -244,9 +240,9 @@ export abstract class GlobUtil { } else { const rel = this.opts.posix ? e.relativePosix() : e.relative() const pre = - this.opts.dotRelative && !rel.startsWith('..' + this.#sep) - ? '.' + this.#sep - : '' + this.opts.dotRelative && !rel.startsWith('..' + this.#sep) ? + '.' + this.#sep + : '' this.matchEmit(!rel ? '.' + mark : pre + rel + mark) } } @@ -272,7 +268,7 @@ export abstract class GlobUtil { target: Path, patterns: Pattern[], processor: Processor, - cb: () => any + cb: () => any, ) { if (this.#childrenIgnored(target)) return cb() if (this.signal?.aborted) cb() @@ -307,7 +303,7 @@ export abstract class GlobUtil { else { t.readdirCB( (_, entries) => this.walkCB3(t, entries, processor, next), - true + true, ) } } @@ -319,7 +315,7 @@ export abstract class GlobUtil { target: Path, entries: Path[], processor: Processor, - cb: () => any + cb: () => any, ) { processor = processor.filterEntries(target, entries) @@ -352,13 +348,13 @@ export abstract class GlobUtil { target: Path, patterns: Pattern[], processor: Processor, - cb: () => any + cb: () => any, ) { if (this.#childrenIgnored(target)) return cb() if (this.signal?.aborted) cb() if (this.paused) { this.onResume(() => - this.walkCB2Sync(target, patterns, processor, cb) + this.walkCB2Sync(target, patterns, processor, cb), ) return } @@ -393,7 +389,7 @@ export abstract class GlobUtil { target: Path, entries: Path[], processor: Processor, - cb: () => any + cb: () => any, ) { processor = processor.filterEntries(target, entries) @@ -416,7 +412,7 @@ export abstract class GlobUtil { } export class GlobWalker< - O extends GlobWalkerOpts = GlobWalkerOpts + O extends GlobWalkerOpts = GlobWalkerOpts, > extends GlobUtil { matches = new Set>() @@ -459,7 +455,7 @@ export class GlobWalker< } export class GlobStream< - O extends GlobWalkerOpts = GlobWalkerOpts + O extends GlobWalkerOpts = GlobWalkerOpts, > extends GlobUtil { results: Minipass, Result> diff --git a/test/00-setup.ts b/test/00-setup.ts index 3b425ce9..7c4e2d7f 100644 --- a/test/00-setup.ts +++ b/test/00-setup.ts @@ -6,7 +6,7 @@ import { createWriteStream, promises } from 'fs' import { mkdirp } from 'mkdirp' import { join, dirname, resolve } from 'path' import t from 'tap' -import {fileURLToPath} from 'url' +import { fileURLToPath } from 'url' const { writeFile, symlink } = promises //@ts-ignore @@ -50,15 +50,15 @@ if (process.platform !== 'win32') { }) } -;['foo', 'bar', 'baz', 'asdf', 'quux', 'qwer', 'rewq'].forEach(function ( - w -) { - w = '/tmp/glob-test/' + w - t.test('create ' + w, async t => { - await mkdirp(w) - t.pass(w) - }) -}) +;['foo', 'bar', 'baz', 'asdf', 'quux', 'qwer', 'rewq'].forEach( + function (w) { + w = '/tmp/glob-test/' + w + t.test('create ' + w, async t => { + await mkdirp(w) + t.pass(w) + }) + }, +) // generate the bash pattern test-fixtures if possible if (process.platform === 'win32' || !process.env.TEST_REGEN) { @@ -154,7 +154,7 @@ export const bashResults:{ [path: string]: string[] } = ${ const c = spawn( 'prettier', ['--write', resolve(__dirname, 'bash-results.ts')], - { stdio: ['ignore', 2, 2] } + { stdio: ['ignore', 2, 2] }, ) c.on('close', (code, signal) => { t.equal(code, 0, 'code') @@ -176,8 +176,8 @@ export const bashResults:{ [path: string]: string[] } = ${ .sort(alphasort) .map(function (f) { // de-windows - return process.platform !== 'win32' - ? f + return process.platform !== 'win32' ? + f : f.replace(/^[a-zA-Z]:\\\\/, '/').replace(/\\/g, '/') }) } diff --git a/test/absolute.ts b/test/absolute.ts index 0707d817..ce0f4d64 100644 --- a/test/absolute.ts +++ b/test/absolute.ts @@ -23,7 +23,7 @@ for (const mark of marks) { t.equal( results.length, bashResults[pattern]?.length, - 'must match all files' + 'must match all files', ) for (const m of results) { t.ok(m.startsWith('/'), 'starts with / ' + m) @@ -37,7 +37,7 @@ for (const mark of marks) { t.equal( results.length, bashResults[pattern]?.length, - 'must match all files' + 'must match all files', ) for (const m of results) { ok(t, m) diff --git a/test/bash-comparison.ts b/test/bash-comparison.ts index 8dd89529..9e35fd1a 100644 --- a/test/bash-comparison.ts +++ b/test/bash-comparison.ts @@ -28,8 +28,8 @@ const cleanResults = (m: string[]) => { }, []) .map(f => { // de-windows - return process.platform !== 'win32' - ? f + return process.platform !== 'win32' ? + f : f.replace(/^[a-zA-Z]:[\/\\]+/, '/').replace(/[\\\/]+/g, '/') }) .sort(alphasort) diff --git a/test/bin.ts b/test/bin.ts index 6f8479a4..c5744f4d 100644 --- a/test/bin.ts +++ b/test/bin.ts @@ -20,7 +20,7 @@ const run = async (args: string[], options = {}) => { const proc = spawn( process.execPath, ['--enable-source-maps', bin, ...args], - options + options, ) const out: Buffer[] = [] const err: Buffer[] = [] @@ -73,8 +73,8 @@ t.test('finds matches for a pattern', async t => { cmd.stdout, `'a${sep.replace(/\\/g, '\\\\')}b${sep.replace( /\\/g, - '\\\\' - )}z.y'`.toUpperCase() + '\\\\', + )}z.y'`.toUpperCase(), ) }) diff --git a/test/broken-symlink.ts b/test/broken-symlink.ts index 4a6555a4..f1520746 100644 --- a/test/broken-symlink.ts +++ b/test/broken-symlink.ts @@ -16,7 +16,7 @@ const dir = relative( link: t.fixture('symlink', 'this-does-not-exist'), }, }, - }) + }), ) const link = `${dir}/a/broken-link/link` diff --git a/test/custom-fs.ts b/test/custom-fs.ts index ee4aafee..fcf812af 100644 --- a/test/custom-fs.ts +++ b/test/custom-fs.ts @@ -23,8 +23,8 @@ t.same( readdirSync: myReaddirSync, }, cwd, - }) - ) + }), + ), ) t.equal(readdirCalled, 2) diff --git a/test/custom-ignore.ts b/test/custom-ignore.ts index a796f08a..53faa36d 100644 --- a/test/custom-ignore.ts +++ b/test/custom-ignore.ts @@ -20,7 +20,7 @@ t.test('ignore files with long names', async t => { const expect = j( globSync('**', { cwd }).filter(p => { return basename(p).length === 1 && basename(p) !== '.' - }) + }), ) t.same(j(syncRes), expect) t.same(j(asyncRes), expect) @@ -40,7 +40,7 @@ t.test('ignore symlink and abcdef directories', async t => { const expect = j( globSync('**', { nodir: true, cwd }).filter(p => { return !/\bsymlink\b|\babcdef\b/.test(p) - }) + }), ) t.same(j(syncRes), expect) t.same(j(asyncRes), expect) diff --git a/test/cwd-noent.ts b/test/cwd-noent.ts index 20896680..dfb7d432 100644 --- a/test/cwd-noent.ts +++ b/test/cwd-noent.ts @@ -2,7 +2,7 @@ import t from 'tap' import { fileURLToPath } from 'url' import { Glob } from '../dist/esm/index.js' const cwd = fileURLToPath( - new URL('./fixtures/does-not-exist', import.meta.url) + new URL('./fixtures/does-not-exist', import.meta.url), ) t.test('walk', async t => { diff --git a/test/cwd-test.ts b/test/cwd-test.ts index 59bf61f4..94047fe5 100644 --- a/test/cwd-test.ts +++ b/test/cwd-test.ts @@ -29,15 +29,15 @@ t.test('changing cwd and searching for **/d', t => { t.same(new Set(await glob('**/d', { cwd: resolve(cwd) })), matches) t.same( new Set(await glob('**/d', { cwd: resolve(cwd) + '/' })), - matches + matches, ) t.same( new Set(await glob('**/d', { cwd: resolve(cwd) + '/.' })), - matches + matches, ) t.same( new Set(await glob('**/d', { cwd: resolve(cwd) + '/./' })), - matches + matches, ) }) } diff --git a/test/dot-relative.ts b/test/dot-relative.ts index 333de61b..ecbed7ee 100644 --- a/test/dot-relative.ts +++ b/test/dot-relative.ts @@ -20,7 +20,7 @@ for (const mark of marks) { t.equal( results.length, bashResults[pattern]?.length, - 'must match all files' + 'must match all files', ) for (const m of results) { t.ok(m.startsWith('.' + sep)) @@ -34,7 +34,7 @@ for (const mark of marks) { t.equal( results.length, bashResults[pattern]?.length, - 'must match all files' + 'must match all files', ) for (const m of results) { t.ok(m.startsWith('.' + sep)) @@ -50,12 +50,12 @@ for (const mark of marks) { t.equal( results.length, bashResults[pattern]?.length, - 'must match all files' + 'must match all files', ) for (const m of results) { t.ok((mark && m === '.' + sep) || !m.startsWith('.' + sep)) } - } + }, ) }) } diff --git a/test/escape.ts b/test/escape.ts index b3314bb9..53e0bc8a 100644 --- a/test/escape.ts +++ b/test/escape.ts @@ -10,11 +10,11 @@ for (const pattern of Object.keys(bashResults)) { }) t.notOk( hasMagic(pp, { platform: 'linux' }), - 'no magic after posix escape' + 'no magic after posix escape', ) t.notOk( hasMagic(pw, { platform: 'win32', windowsPathsNoEscape: true }), - 'no magic after windows escape' + 'no magic after windows escape', ) const up = unescape(pp) const uw = unescape(pw, { windowsPathsNoEscape: true }) diff --git a/test/follow.ts b/test/follow.ts index f5b68b03..8b6f57b4 100644 --- a/test/follow.ts +++ b/test/follow.ts @@ -20,12 +20,12 @@ t.test('follow symlinks', async t => { t.same( new Set(follow), new Set(syncFollow), - 'sync and async follow should match' + 'sync and async follow should match', ) t.same( new Set(noFollow), new Set(syncNoFollow), - 'sync and async noFollow should match' + 'sync and async noFollow should match', ) var long = 'a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c' t.ok(follow.includes(long), 'follow should have long entry') diff --git a/test/has-magic.ts b/test/has-magic.ts index 96903d19..f06b5ff1 100644 --- a/test/has-magic.ts +++ b/test/has-magic.ts @@ -22,19 +22,19 @@ t.test('detect magic in glob patterns', async t => { t.ok(glob.hasMagic('a/b/+(x|y)'), 'magic in a/b/+(x|y)') t.notOk( glob.hasMagic('a/b/+(x|y)', { noext: true }), - 'no magic in a/b/+(x|y) noext' + 'no magic in a/b/+(x|y) noext', ) t.notOk(glob.hasMagic('{a,b}'), 'no magic in {a,b}') t.ok( glob.hasMagic('{a,b}', { magicalBraces: true }), - 'magical braces are magic in {a,b}' + 'magical braces are magic in {a,b}', ) t.notOk( glob.hasMagic('{a,b}', { nobrace: true }), - 'no magic in {a,b} nobrace:true' + 'no magic in {a,b} nobrace:true', ) t.notOk( glob.hasMagic('{a,b}', { nobrace: true, magicalBraces: true }), - 'magical braces not magic in {a,b} nobrace:true' + 'magical braces not magic in {a,b} nobrace:true', ) }) diff --git a/test/ignore.ts b/test/ignore.ts index 26865f6b..86864a08 100644 --- a/test/ignore.ts +++ b/test/ignore.ts @@ -19,7 +19,7 @@ type Case = [ pattern: string, ignore: null | string | string[], expect: string[], - optOrCwd?: GlobOptions | string | undefined + optOrCwd?: GlobOptions | string | undefined, ] const cases: Case[] = [ @@ -354,15 +354,14 @@ const cases: Case[] = [ for (const c of cases) { const [pattern, ignore, ex, optCwd] = c const expect = ( - process.platform === 'win32' - ? ex.filter(e => !/\bsymlink\b/.test(e)) - : ex - ).sort() + process.platform === 'win32' ? + ex.filter(e => !/\bsymlink\b/.test(e)) + : ex).sort() expect.sort() const opt: GlobOptions = (typeof optCwd === 'string' ? { cwd: optCwd } : optCwd) || {} const name = `p=${pattern} i=${JSON.stringify(ignore)} ${JSON.stringify( - opt + opt, )}` if (ignore) { diff --git a/test/include-child-matches.ts b/test/include-child-matches.ts index c23a5182..96a337a7 100644 --- a/test/include-child-matches.ts +++ b/test/include-child-matches.ts @@ -29,17 +29,19 @@ t.test('test the caveat', async t => { } const a = await glob(pattern, o) const s = globSync(pattern, o) - t.strictSame(a, [ 'a/b/c/d/e/f', 'a/b/c/d/e' ]) - t.strictSame(s, [ 'a/b/c/d/e/f', 'a/b/c/d/e' ]) + t.strictSame(a, ['a/b/c/d/e/f', 'a/b/c/d/e']) + t.strictSame(s, ['a/b/c/d/e/f', 'a/b/c/d/e']) }) t.test('ignore impl must have an add() method', t => { - t.throws(() => globSync('', { - ignore: { - ignored: () => true, - childrenIgnored: () => true, - }, - includeChildMatches: false, - })) + t.throws(() => + globSync('', { + ignore: { + ignored: () => true, + childrenIgnored: () => true, + }, + includeChildMatches: false, + }), + ) t.end() }) diff --git a/test/match-base.ts b/test/match-base.ts index 9bdcebcf..32cb2efd 100644 --- a/test/match-base.ts +++ b/test/match-base.ts @@ -22,11 +22,11 @@ t.test('chdir', async t => { t.teardown(() => process.chdir(origCwd)) t.same( glob.globSync(pattern, { matchBase: true }).sort(alphasort), - j(expect) + j(expect), ) t.same( (await glob(pattern, { matchBase: true })).sort(alphasort), - j(expect) + j(expect), ) }) @@ -35,20 +35,20 @@ t.test('cwd', async t => { glob .globSync(pattern, { matchBase: true, cwd: fixtureDir }) .sort(alphasort), - j(expect) + j(expect), ) t.same( (await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort( - alphasort + alphasort, ), - j(expect) + j(expect), ) }) t.test('noglobstar', async t => { t.rejects(glob(pattern, { matchBase: true, noglobstar: true })) t.throws(() => - glob.globSync(pattern, { matchBase: true, noglobstar: true }) + glob.globSync(pattern, { matchBase: true, noglobstar: true }), ) t.end() }) @@ -60,13 +60,13 @@ t.test('pattern includes /', async t => { glob .globSync(pattern, { matchBase: true, cwd: fixtureDir }) .sort(alphasort), - j(expect) + j(expect), ) t.same( (await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort( - alphasort + alphasort, ), - j(expect) + j(expect), ) }) @@ -77,13 +77,13 @@ t.test('one brace section of pattern includes /', async t => { glob .globSync(pattern, { matchBase: true, cwd: fixtureDir }) .sort(alphasort), - j(exp) + j(exp), ) t.same( (await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort( - alphasort + alphasort, ), - j(exp) + j(exp), ) }) @@ -94,12 +94,12 @@ t.test('one array member of pattern includes /', async t => { glob .globSync(pattern, { matchBase: true, cwd: fixtureDir }) .sort(alphasort), - j(exp) + j(exp), ) t.same( (await glob(pattern, { matchBase: true, cwd: fixtureDir })).sort( - alphasort + alphasort, ), - j(exp) + j(exp), ) }) diff --git a/test/max-depth.ts b/test/max-depth.ts index cb65c384..ec183e86 100644 --- a/test/max-depth.ts +++ b/test/max-depth.ts @@ -17,7 +17,7 @@ const j = (a: string[]) => t.test('set maxDepth', async t => { const maxDepth = 2 const cwd = resolve( - fileURLToPath(new URL('./fixtures', import.meta.url)) + fileURLToPath(new URL('./fixtures', import.meta.url)), ) const startDepth = new PathScurry(cwd).cwd.depth() const pattern = '{*/*/*/**,*/*/**,**}' @@ -41,7 +41,7 @@ t.test('set maxDepth', async t => { const expect = j( noMaxDepth .filter(p => p.depth() <= startDepth + maxDepth) - .map(p => p.relative() || '.') + .map(p => p.relative() || '.'), ) const ssync = j(syncRes.map(p => p.relative() || '.')) @@ -67,10 +67,10 @@ t.test('set maxDepth', async t => { t.same( j( - await globStream(pattern, { cwd, maxDepth, follow: true }).collect() + await globStream(pattern, { cwd, maxDepth, follow: true }).collect(), ), expect, - 'maxDepth with stream' + 'maxDepth with stream', ) t.same( j( @@ -78,32 +78,32 @@ t.test('set maxDepth', async t => { cwd, maxDepth, follow: true, - }).collect() + }).collect(), ), expect, - 'maxDepth with streamSync' + 'maxDepth with streamSync', ) t.same( await glob(pattern, { cwd, maxDepth: -1, follow: true }), [], - 'async maxDepth -1' + 'async maxDepth -1', ) t.same( globSync(pattern, { cwd, maxDepth: -1, follow: true }), [], - 'sync maxDepth -1' + 'sync maxDepth -1', ) t.same( await glob(pattern, { cwd, maxDepth: 0, follow: true }), ['.'], - 'async maxDepth 0' + 'async maxDepth 0', ) t.same( globSync(pattern, { cwd, maxDepth: 0, follow: true }), ['.'], - 'async maxDepth 0' + 'async maxDepth 0', ) const g = new Glob(pattern, { cwd, follow: true, maxDepth }) diff --git a/test/memfs.ts b/test/memfs.ts index f4ff2f01..40bce90c 100644 --- a/test/memfs.ts +++ b/test/memfs.ts @@ -26,8 +26,8 @@ for (const pattern of patterns) { t.test('mocking the fs', async t => { const { glob } = (await t.mockImport( '../dist/esm/index.js', - mock - )) as typeof import('../dist/esm/index.js') + mock, + )) as typeof import('../dist/esm/index.js') t.strictSame(await glob(pattern, { nodir: true, cwd }), ['/x']) }) t.test('passing in fs argument', async t => { diff --git a/test/nodir.ts b/test/nodir.ts index 9e667ea7..cd3dd204 100644 --- a/test/nodir.ts +++ b/test/nodir.ts @@ -39,9 +39,9 @@ const cases: [string, GlobOptions, string[]][] = [ for (const [pattern, options, expectRaw] of cases) { options.nodir = true const expect = - process.platform === 'win32' - ? expectRaw.filter(e => !/\bsymlink\b/.test(e)) - : expectRaw + process.platform === 'win32' ? + expectRaw.filter(e => !/\bsymlink\b/.test(e)) + : expectRaw expect.sort() if (process.platform !== 'win32') { } diff --git a/test/pattern.ts b/test/pattern.ts index 8fb2e776..7ea6aae2 100644 --- a/test/pattern.ts +++ b/test/pattern.ts @@ -15,7 +15,7 @@ t.same( 'c:/x/*', 'c:/', ], - { platform: 'win32' } + { platform: 'win32' }, ).patterns.map(p => [p.globString(), p.root()]), [ ['//host/share/x/*', '//host/share/'], @@ -26,7 +26,7 @@ t.same( ['//?/z:/', '//?/z:/'], ['c:/x/*', 'c:/'], ['c:/', 'c:/'], - ] + ], ) t.throws(() => { new Pattern([], ['x'], 0, process.platform) @@ -53,7 +53,7 @@ const g = new Pattern( [GLOBSTAR as unknown as MMPattern], ['**'], 0, - process.platform + process.platform, ) const r = new Pattern([/./], ['?'], 0, process.platform) t.equal(s.isString(), true) diff --git a/test/platform.ts b/test/platform.ts index c054bc91..187d1270 100644 --- a/test/platform.ts +++ b/test/platform.ts @@ -32,7 +32,7 @@ t.test('default linux when not found', async t => { }) const { Glob } = (await t.mockImport( '../dist/esm/index.js', - {} + {}, )) as typeof import('../dist/esm/index.js') const g = new Glob('.', {}) t.equal(g.platform, 'linux') @@ -42,15 +42,15 @@ t.test('default linux when not found', async t => { t.test('set platform, get appropriate scurry object', t => { t.equal( new Glob('.', { platform: 'darwin' }).scurry.constructor, - PathScurryDarwin + PathScurryDarwin, ) t.equal( new Glob('.', { platform: 'linux' }).scurry.constructor, - PathScurryPosix + PathScurryPosix, ) t.equal( new Glob('.', { platform: 'win32' }).scurry.constructor, - PathScurryWin32 + PathScurryWin32, ) t.equal(new Glob('.', {}).scurry.constructor, PathScurry) t.end() diff --git a/test/progra-tilde.ts b/test/progra-tilde.ts index 9168f6ed..57dae955 100644 --- a/test/progra-tilde.ts +++ b/test/progra-tilde.ts @@ -18,7 +18,7 @@ const dir = t.testdir({ t.strictSame( globSync('progra~1\\*', { cwd: dir, windowsPathsNoEscape: true }).sort( - (a, b) => a.localeCompare(b, 'en') + (a, b) => a.localeCompare(b, 'en'), ), - ['progra~1\\a', 'progra~1\\b', 'progra~1\\c'] + ['progra~1\\a', 'progra~1\\b', 'progra~1\\c'], ) diff --git a/test/realpath.ts b/test/realpath.ts index bd09a1e9..6665a339 100644 --- a/test/realpath.ts +++ b/test/realpath.ts @@ -4,7 +4,7 @@ import { resolve } from 'path' import t from 'tap' import { glob } from '../dist/esm/index.js' import { GlobOptionsWithFileTypesUnset } from '../dist/esm/glob.js' -import {fileURLToPath} from 'url' +import { fileURLToPath } from 'url' const alphasort = (a: string, b: string) => a.localeCompare(b, 'en') @@ -24,7 +24,7 @@ if (process.platform === 'win32') { type Case = [ options: GlobOptionsWithFileTypesUnset, results: string[], - pattern?: string + pattern?: string, ] const cases: Case[] = [ [{}, ['a/symlink', 'a/symlink/a', 'a/symlink/a/b']], @@ -66,7 +66,7 @@ if (process.platform === 'win32') { t.test('realpath failure', async t => { // failing realpath means that it does not include the result process.chdir(origCwd) - const { glob } = await t.mockImport('../dist/esm/index.js', { + const { glob } = (await t.mockImport('../dist/esm/index.js', { fs: { ...fs, realpathSync: Object.assign(fs.realpathSync, { @@ -81,18 +81,18 @@ if (process.platform === 'win32') { throw new Error('no error for you async') }, }, - }) as typeof import('../dist/esm/index.js') + })) as typeof import('../dist/esm/index.js') const pattern = 'a/symlink/a/b/c/a/b/**' t.test('setting cwd explicitly', async t => { const opt = { realpath: true, cwd: fixtureDir } t.same(glob.globSync(pattern, opt), []) - t.same((await glob(pattern, opt)), []) + t.same(await glob(pattern, opt), []) }) t.test('looking in cwd', async t => { process.chdir(fixtureDir) const opt = { realpath: true } t.same(glob.globSync(pattern, opt), []) - t.same((await glob(pattern, opt)), []) + t.same(await glob(pattern, opt), []) }) }) } diff --git a/test/signal.ts b/test/signal.ts index a116552a..20dd435a 100644 --- a/test/signal.ts +++ b/test/signal.ts @@ -48,7 +48,7 @@ t.test('mid-abort sync walk', async t => { const ac = new AbortController() const { globSync } = await t.mockImport( '../dist/esm/index.js', - mocks(ac) + mocks(ac), ) t.throws(() => globSync('./**', { cwd, signal: ac.signal })) }) diff --git a/test/stat.ts b/test/stat.ts index 0b0899d9..1d993ba7 100644 --- a/test/stat.ts +++ b/test/stat.ts @@ -1,6 +1,6 @@ import { resolve } from 'path' import t from 'tap' -import {fileURLToPath} from 'url' +import { fileURLToPath } from 'url' import { glob, globSync } from '../dist/esm/index.js' const __dirname = fileURLToPath(new URL('.', import.meta.url)) diff --git a/test/stream.ts b/test/stream.ts index fb53c07a..fb74a452 100644 --- a/test/stream.ts +++ b/test/stream.ts @@ -1,6 +1,6 @@ import { resolve, sep } from 'path' import t from 'tap' -import {fileURLToPath} from 'url' +import { fileURLToPath } from 'url' import { Glob, globIterate, @@ -35,9 +35,9 @@ const expect = j([ 'abcfed/g/h', 'abcdef/g', 'abcdef/g/h', - ...(process.platform !== 'win32' - ? ['symlink', 'symlink/a', 'symlink/a/b', 'symlink/a/b/c'] - : []), + ...(process.platform !== 'win32' ? + ['symlink', 'symlink/a', 'symlink/a/b', 'symlink/a/b/c'] + : []), ]) t.test('stream', t => { diff --git a/test/windows-paths-fs.ts b/test/windows-paths-fs.ts index 086365f4..a90adc25 100644 --- a/test/windows-paths-fs.ts +++ b/test/windows-paths-fs.ts @@ -33,14 +33,14 @@ t.test('treat backslash as escape', t => { t.strictSame( glob.globSync(pattern, { cwd: dir, posix: true }), expect, - 'sync' + 'sync', ) t.strictSame( (await glob(pattern, { cwd: dir })).map(s => - s.replace(/\\/g, '/') + s.replace(/\\/g, '/'), ), expect, - 'async' + 'async', ) }) } @@ -63,14 +63,14 @@ t.test('treat backslash as separator', t => { .globSync(pattern, { cwd: dir, windowsPathsNoEscape: true }) .map(s => s.replace(/\\/g, '/')), expect, - 'sync' + 'sync', ) t.strictSame( ( await glob(pattern, { cwd: dir, windowsPathsNoEscape: true }) ).map(s => s.replace(/\\/g, '/')), expect, - 'async' + 'async', ) }) } diff --git a/test/windows-paths-no-escape.ts b/test/windows-paths-no-escape.ts index b5b2d9d2..ac2c266f 100644 --- a/test/windows-paths-no-escape.ts +++ b/test/windows-paths-no-escape.ts @@ -4,7 +4,7 @@ import { Glob } from '../dist/esm/index.js' const platforms = ['win32', 'posix'] const originalPlatform = Object.getOwnPropertyDescriptor( process, - 'platform' + 'platform', ) as PropertyDescriptor t.teardown(() => { Object.defineProperty(process, 'platform', originalPlatform) @@ -43,7 +43,7 @@ for (const p of platforms) { ['/a/b/c/x\\[a-b\\]y\\*'], ['/a/b/c/x/[a-b/]y/*'], ['/a/b/c/x/[a-b/]y/*'], - ] + ], ) t.end() })