Skip to content

Commit

Permalink
omit symlinks on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 27, 2023
1 parent d34c8d5 commit 210310b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
9 changes: 6 additions & 3 deletions src/walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ export abstract class GlobUtil<O extends GlobWalkerOpts = GlobWalkerOpts> {
onResume(fn: () => any) {
if (this.signal?.aborted) return
/* c8 ignore start */
if (!this.paused) fn()
/* c8 ignore stop */
else this.#onResume.push(fn)
if (!this.paused) {
fn()
} else {
/* c8 ignore stop */
this.#onResume.push(fn)
}
}

// do the requisite realpath/stat checking, and return the path
Expand Down
4 changes: 3 additions & 1 deletion test/match-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ t.test('cwd', async t => {

t.test('noglobstar', async t => {
t.rejects(glob(pattern, { matchBase: true, noglobstar: true }))
t.throws(() => glob.globSync(pattern, { matchBase: true, noglobstar: true }))
t.throws(() =>
glob.globSync(pattern, { matchBase: true, noglobstar: true })
)
t.end()
})

Expand Down
4 changes: 2 additions & 2 deletions test/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
} from 'path-scurry'
import { Glob } from '../'
import { glob } from '../dist/cjs'
import {GlobWalker} from '../dist/cjs/walker'
import {Pattern} from '../dist/cjs/pattern'
import { GlobWalker } from '../dist/cjs/walker'
import { Pattern } from '../dist/cjs/pattern'

t.test('default platform is process.platform', t => {
const g = new Glob('.', {})
Expand Down
13 changes: 6 additions & 7 deletions test/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ import {
globStream,
globStreamSync,
} from '../'
import {glob, globSync} from '../dist/cjs'
import { glob, globSync } from '../dist/cjs'
const cwd = resolve(__dirname, 'fixtures/a')
const j = (a: string[]) => a.map(a => a.split('/').join(sep))
const expect = j([
'',
'z',
'x',
'symlink',
'cb',
'c',
'bc',
'b',
'abcfed',
'abcdef',
'symlink/a',
'symlink/a/b',
'symlink/a/b/c',
'cb/e',
'cb/e/f',
'c/d',
Expand All @@ -37,6 +33,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']
: []),
])

t.test('stream', t => {
Expand Down Expand Up @@ -136,7 +135,7 @@ t.test('walk', async t => {
const actual = new Set(await s.walk())
t.same(actual, e)
const d = new Glob('./**', s)
const dactual= new Set(await d.walk())
const dactual = new Set(await d.walk())
t.same(dactual, e)
})

Expand All @@ -146,7 +145,7 @@ t.test('walkSync', t => {
const actual = new Set(s.walkSync())
t.same(actual, e)
const d = new Glob('./**', s)
const dactual= new Set(d.walkSync())
const dactual = new Set(d.walkSync())
t.same(dactual, e)
t.end()
})
Expand Down
4 changes: 3 additions & 1 deletion test/windows-paths-fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ t.test('treat backslash as escape', t => {
for (const [pattern, expect] of cases) {
t.test(pattern, async t => {
t.strictSame(
glob.globSync(pattern, { cwd: dir }).map(s => s.replace(/\\/g, '/')),
glob
.globSync(pattern, { cwd: dir })
.map(s => s.replace(/\\/g, '/')),
expect,
'sync'
)
Expand Down

0 comments on commit 210310b

Please sign in to comment.