Skip to content

Commit

Permalink
test posix:true in a way that works on win32
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 15, 2023
1 parent bfc1c9f commit 943619b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/absolute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ for (const mark of marks) {
t.plan(2)

t.test('Emits absolute matches if option set', async t => {
var g = new Glob(pattern, { absolute: true })
var g = new Glob(pattern, { absolute: true, posix: true })
const results = await g.walk()

t.equal(
Expand All @@ -24,7 +24,7 @@ for (const mark of marks) {
'must match all files'
)
for (const m of results) {
ok(t, m)
t.ok(m.startsWith('/'), 'starts with / ' + m)
}
})

Expand Down
13 changes: 5 additions & 8 deletions test/mark.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { sep } from 'path'
import t from 'tap'
import { glob } from '../'
process.chdir(__dirname + '/fixtures')

const alphasort = (a: string, b: string) => a.localeCompare(b, 'en')
import { sep } from 'path'
const j = (a: string[]) =>
a.map(s => s.split('/').join(sep)).sort(alphasort)

Expand Down Expand Up @@ -146,14 +146,11 @@ for (const mark of [true, false]) {
for (const slash of [true, false]) {
t.test('cwd mark:' + mark + ' slash:' + slash, async t => {
const pattern = cwd + (slash ? '/' : '')
const results = await glob(pattern, { mark, posix: true })
const results = await glob(pattern, { mark })
t.equal(results.length, 1)
const res = results[0]
const syncResults = glob.globSync(pattern, {
mark: mark,
posix: true,
})
const syncRes = syncResults[0]
const res = results[0].replace(/\\/g, '/')
const syncResults = glob.globSync(pattern, { mark: mark })
const syncRes = syncResults[0].replace(/\\/g, '/')
if (mark) {
t.equal(res, cwd + '/')
} else {
Expand Down

0 comments on commit 943619b

Please sign in to comment.