Skip to content

Commit 057d5b2

Browse files
committed
update prettier, format everything
1 parent 10162fb commit 057d5b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+308
-305
lines changed

.prettierignore

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
/node_modules
2-
/example
31
/.github
2+
/.tap
3+
/node_modules
4+
/tap-snapshots
5+
6+
/scripts/fixtures
7+
/.tap
8+
/.tshy
49
/dist
5-
.env
10+
/docs
11+
/example
12+
/node_modules
613
/tap-snapshots
7-
/.nyc_output
8-
/coverage
9-
/benchmark
10-
/scripts/fixture
11-
/test/fixture
14+
/test/**/fixture
15+
/test/**/fixtures

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ g3.stream().on('data', path => {
7777
'got a path object',
7878
path.fullpath(),
7979
path.isDirectory(),
80-
path.readdirSync().map(e => e.name)
80+
path.readdirSync().map(e => e.name),
8181
)
8282
})
8383

@@ -606,28 +606,31 @@ share the previously loaded cache.
606606
`false`, and a custom `Ignore` is provided that does not have
607607
an `add()` method, then it will throw an error.
608608

609-
**Caveat** It *only* ignores matches that would be a descendant
609+
**Caveat** It _only_ ignores matches that would be a descendant
610610
of a previous match, and only if that descendant is matched
611-
*after* the ancestor is encountered. Since the file system walk
611+
_after_ the ancestor is encountered. Since the file system walk
612612
happens in indeterminate order, it's possible that a match will
613613
already be added before its ancestor, if multiple or braced
614614
patterns are used.
615615

616616
For example:
617617

618618
```js
619-
const results = await glob([
620-
// likely to match first, since it's just a stat
621-
'a/b/c/d/e/f',
622-
623-
// this pattern is more complicated! It must to various readdir()
624-
// calls and test the results against a regular expression, and that
625-
// is certainly going to take a little bit longer.
626-
//
627-
// So, later on, it encounters a match at 'a/b/c/d/e', but it's too
628-
// late to ignore a/b/c/d/e/f, because it's already been emitted.
629-
'a/[bdf]/?/[a-z]/*',
630-
], { includeChildMatches: false })
619+
const results = await glob(
620+
[
621+
// likely to match first, since it's just a stat
622+
'a/b/c/d/e/f',
623+
624+
// this pattern is more complicated! It must to various readdir()
625+
// calls and test the results against a regular expression, and that
626+
// is certainly going to take a little bit longer.
627+
//
628+
// So, later on, it encounters a match at 'a/b/c/d/e', but it's too
629+
// late to ignore a/b/c/d/e/f, because it's already been emitted.
630+
'a/[bdf]/?/[a-z]/*',
631+
],
632+
{ includeChildMatches: false },
633+
)
631634
```
632635

633636
It's best to only set this to `false` if you can be reasonably

examples/g.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ console.log(pattern)
55

66
var mg = new Glob(pattern, { mark: true, sync: true }, function (
77
er,
8-
matches
8+
matches,
99
) {
1010
console.log('matches', matches)
1111
})

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"presnap": "npm run prepare",
4444
"test": "tap",
4545
"snap": "tap",
46-
"format": "prettier --write . --loglevel warn",
46+
"format": "prettier --write . --log-level warn",
4747
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts",
4848
"prepublish": "npm run benchclean",
4949
"profclean": "rm -f v8.log profile.txt",
@@ -55,6 +55,7 @@
5555
"benchclean": "node benchclean.cjs"
5656
},
5757
"prettier": {
58+
"experimentalTernaries": true,
5859
"semi": false,
5960
"printWidth": 75,
6061
"tabWidth": 2,
@@ -76,7 +77,7 @@
7677
"@types/node": "^20.11.30",
7778
"memfs": "^3.4.13",
7879
"mkdirp": "^3.0.1",
79-
"prettier": "^2.8.3",
80+
"prettier": "^3.2.5",
8081
"rimraf": "^5.0.7",
8182
"sync-content": "^1.0.2",
8283
"tap": "^19.0.0",

src/bin.mts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { globStream } from './index.js'
1111
const { version } = JSON.parse(
1212
await readFile(
1313
fileURLToPath(new URL('../../package.json', import.meta.url)),
14-
'utf8'
14+
'utf8',
1515
).catch(() =>
1616
readFile(
1717
fileURLToPath(new URL('../../package.json', import.meta.url)),
18-
'utf8'
19-
)
20-
)
18+
'utf8',
19+
),
20+
),
2121
) as { version: string }
2222
/* c8 ignore stop */
2323

@@ -30,7 +30,7 @@ const j = jack({
3030
3131
Expand the positional glob expression arguments into any matching file
3232
system paths found.
33-
`
33+
`,
3434
)
3535
.opt({
3636
cmd: {
@@ -202,18 +202,18 @@ const j = jack({
202202
available, or 'linux' if not. Setting --platform=win32
203203
on non-Windows systems may cause strange behavior!`,
204204
validOptions: [
205-
'aix',
206-
'android',
207-
'darwin',
208-
'freebsd',
209-
'haiku',
210-
'linux',
211-
'openbsd',
212-
'sunos',
213-
'win32',
214-
'cygwin',
215-
'netbsd',
216-
]
205+
'aix',
206+
'android',
207+
'darwin',
208+
'freebsd',
209+
'haiku',
210+
'linux',
211+
'openbsd',
212+
'sunos',
213+
'win32',
214+
'cygwin',
215+
'netbsd',
216+
],
217217
},
218218
})
219219
.optList({
@@ -246,11 +246,11 @@ try {
246246
throw 'No patterns provided'
247247
if (positionals.length === 0 && values.default)
248248
positionals.push(values.default)
249-
const patterns = values.all
250-
? positionals
251-
: positionals.filter(p => !existsSync(p))
252-
const matches = values.all
253-
? []
249+
const patterns =
250+
values.all ? positionals : positionals.filter(p => !existsSync(p))
251+
const matches =
252+
values.all ?
253+
[]
254254
: positionals.filter(p => existsSync(p)).map(p => join(p))
255255
const stream = globStream(patterns, {
256256
absolute: values.absolute,

src/glob.ts

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ export type GlobParts = Exclude<Minimatch['globParts'], undefined>
1919
// if no process global, just call it linux.
2020
// so we default to case-sensitive, / separators
2121
const defaultPlatform: NodeJS.Platform =
22-
typeof process === 'object' &&
23-
process &&
24-
typeof process.platform === 'string'
25-
? process.platform
26-
: 'linux'
22+
(
23+
typeof process === 'object' &&
24+
process &&
25+
typeof process.platform === 'string'
26+
) ?
27+
process.platform
28+
: 'linux'
2729

2830
/**
2931
* A `GlobOptions` object may be provided to any of the exported methods, and
@@ -355,21 +357,17 @@ export type GlobOptionsWithFileTypesUnset = GlobOptions & {
355357
withFileTypes?: undefined
356358
}
357359

358-
export type Result<Opts> = Opts extends GlobOptionsWithFileTypesTrue
359-
? Path
360-
: Opts extends GlobOptionsWithFileTypesFalse
361-
? string
362-
: Opts extends GlobOptionsWithFileTypesUnset
363-
? string
360+
export type Result<Opts> =
361+
Opts extends GlobOptionsWithFileTypesTrue ? Path
362+
: Opts extends GlobOptionsWithFileTypesFalse ? string
363+
: Opts extends GlobOptionsWithFileTypesUnset ? string
364364
: string | Path
365365
export type Results<Opts> = Result<Opts>[]
366366

367-
export type FileTypes<Opts> = Opts extends GlobOptionsWithFileTypesTrue
368-
? true
369-
: Opts extends GlobOptionsWithFileTypesFalse
370-
? false
371-
: Opts extends GlobOptionsWithFileTypesUnset
372-
? false
367+
export type FileTypes<Opts> =
368+
Opts extends GlobOptionsWithFileTypesTrue ? true
369+
: Opts extends GlobOptionsWithFileTypesFalse ? false
370+
: Opts extends GlobOptionsWithFileTypesUnset ? false
373371
: boolean
374372

375373
/**
@@ -494,13 +492,10 @@ export class Glob<Opts extends GlobOptions> implements GlobOptions {
494492
}
495493
} else {
496494
const Scurry =
497-
opts.platform === 'win32'
498-
? PathScurryWin32
499-
: opts.platform === 'darwin'
500-
? PathScurryDarwin
501-
: opts.platform
502-
? PathScurryPosix
503-
: PathScurry
495+
opts.platform === 'win32' ? PathScurryWin32
496+
: opts.platform === 'darwin' ? PathScurryDarwin
497+
: opts.platform ? PathScurryPosix
498+
: PathScurry
504499
this.scurry = new Scurry(this.cwd, {
505500
nocase: opts.nocase,
506501
fs: opts.fs,
@@ -539,7 +534,7 @@ export class Glob<Opts extends GlobOptions> implements GlobOptions {
539534
set[1].push(...m.globParts)
540535
return set
541536
},
542-
[[], []]
537+
[[], []],
543538
)
544539
this.patterns = matchSet.map((set, i) => {
545540
const g = globParts[i]
@@ -563,9 +558,9 @@ export class Glob<Opts extends GlobOptions> implements GlobOptions {
563558
...(await new GlobWalker(this.patterns, this.scurry.cwd, {
564559
...this.opts,
565560
maxDepth:
566-
this.maxDepth !== Infinity
567-
? this.maxDepth + this.scurry.cwd.depth()
568-
: Infinity,
561+
this.maxDepth !== Infinity ?
562+
this.maxDepth + this.scurry.cwd.depth()
563+
: Infinity,
569564
platform: this.platform,
570565
nocase: this.nocase,
571566
includeChildMatches: this.includeChildMatches,
@@ -582,9 +577,9 @@ export class Glob<Opts extends GlobOptions> implements GlobOptions {
582577
...new GlobWalker(this.patterns, this.scurry.cwd, {
583578
...this.opts,
584579
maxDepth:
585-
this.maxDepth !== Infinity
586-
? this.maxDepth + this.scurry.cwd.depth()
587-
: Infinity,
580+
this.maxDepth !== Infinity ?
581+
this.maxDepth + this.scurry.cwd.depth()
582+
: Infinity,
588583
platform: this.platform,
589584
nocase: this.nocase,
590585
includeChildMatches: this.includeChildMatches,
@@ -600,9 +595,9 @@ export class Glob<Opts extends GlobOptions> implements GlobOptions {
600595
return new GlobStream(this.patterns, this.scurry.cwd, {
601596
...this.opts,
602597
maxDepth:
603-
this.maxDepth !== Infinity
604-
? this.maxDepth + this.scurry.cwd.depth()
605-
: Infinity,
598+
this.maxDepth !== Infinity ?
599+
this.maxDepth + this.scurry.cwd.depth()
600+
: Infinity,
606601
platform: this.platform,
607602
nocase: this.nocase,
608603
includeChildMatches: this.includeChildMatches,
@@ -617,9 +612,9 @@ export class Glob<Opts extends GlobOptions> implements GlobOptions {
617612
return new GlobStream(this.patterns, this.scurry.cwd, {
618613
...this.opts,
619614
maxDepth:
620-
this.maxDepth !== Infinity
621-
? this.maxDepth + this.scurry.cwd.depth()
622-
: Infinity,
615+
this.maxDepth !== Infinity ?
616+
this.maxDepth + this.scurry.cwd.depth()
617+
: Infinity,
623618
platform: this.platform,
624619
nocase: this.nocase,
625620
includeChildMatches: this.includeChildMatches,

src/has-magic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { GlobOptions } from './glob.js'
1414
*/
1515
export const hasMagic = (
1616
pattern: string | string[],
17-
options: GlobOptions = {}
17+
options: GlobOptions = {},
1818
): boolean => {
1919
if (!Array.isArray(pattern)) {
2020
pattern = [pattern]

src/ignore.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ export interface IgnoreLike {
1515
}
1616

1717
const defaultPlatform: NodeJS.Platform =
18-
typeof process === 'object' &&
19-
process &&
20-
typeof process.platform === 'string'
21-
? process.platform
22-
: 'linux'
18+
(
19+
typeof process === 'object' &&
20+
process &&
21+
typeof process.platform === 'string'
22+
) ?
23+
process.platform
24+
: 'linux'
2325

2426
/**
2527
* Class used to process ignored patterns
@@ -40,7 +42,7 @@ export class Ignore implements IgnoreLike {
4042
noext,
4143
noglobstar,
4244
platform = defaultPlatform,
43-
}: GlobWalkerOpts
45+
}: GlobWalkerOpts,
4446
) {
4547
this.relative = []
4648
this.absolute = []

0 commit comments

Comments
 (0)