Skip to content

Commit ebd167d

Browse files
committed
normalize paths in tests for Windows' benefit
1 parent 11cd075 commit ebd167d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
MkdirpOptionsResolved,
77
} from '../dist/cjs/src/opts-arg.js'
88

9+
const s = (s: any) => typeof s !== 'string' ? s : s.replace(/\\/g, '/')
10+
911
// node before 10.13 didn't native recursive mkdir
1012
const doNative = !/^v([0-8]\.|10.([0-9]\.|10\.|11\.([0-9]|1[01])$))/.test(
1113
process.version
@@ -26,16 +28,16 @@ t.test('module shape', t => {
2628
t.test('basic making of dirs should work', async t => {
2729
const dir = t.testdir({ a: {} })
2830
const check = (d: string) => t.ok(statSync(d).isDirectory())
29-
t.equal(mkdirp.sync(`${dir}/a/sync`), `${dir}/a/sync`)
31+
t.equal(s(mkdirp.sync(`${dir}/a/sync`)), `${dir}/a/sync`)
3032
check(`${dir}/a/sync`)
3133
t.equal(mkdirp.sync(`${dir}/a/sync`), undefined)
3234

33-
t.equal(mkdirp.manualSync(`${dir}/a/manual-sync`), `${dir}/a/manual-sync`)
35+
t.equal(s(mkdirp.manualSync(`${dir}/a/manual-sync`)), `${dir}/a/manual-sync`)
3436
check(`${dir}/a/manual-sync`)
35-
t.equal(mkdirp.manualSync(`${dir}/a/manual-sync`), undefined)
37+
t.equal(s(mkdirp.manualSync(`${dir}/a/manual-sync`)), undefined)
3638

3739
if (doNative) {
38-
t.equal(mkdirp.nativeSync(`${dir}/a/native-sync`), `${dir}/a/native-sync`)
40+
t.equal(s(mkdirp.nativeSync(`${dir}/a/native-sync`)), `${dir}/a/native-sync`)
3941
check(`${dir}/a/native-sync`)
4042
t.equal(mkdirp.nativeSync(`${dir}/a/native-sync`), undefined)
4143
}
@@ -51,10 +53,10 @@ t.test('basic making of dirs should work', async t => {
5153
mkdirSync(path, opts)
5254
const opts = { mkdir: myMkdir, mkdirSync: myMkdirSync }
5355
//@ts-ignore
54-
t.equal(mkdirp.sync(`${dir}/a/custom-sync`, opts), `${dir}/a/custom-sync`)
56+
t.equal(s(mkdirp.sync(`${dir}/a/custom-sync`, opts)), `${dir}/a/custom-sync`)
5557
check(`${dir}/a/custom-sync`)
5658
//@ts-ignore
57-
t.equal(mkdirp.sync(`${dir}/a/custom-sync`, opts), undefined)
59+
t.equal(s(mkdirp.sync(`${dir}/a/custom-sync`, opts)), undefined)
5860

5961
return Promise.all([
6062
mkdirp(`${dir}/a/async`),
@@ -64,7 +66,7 @@ t.test('basic making of dirs should work', async t => {
6466
mkdirp(`${dir}/a/custom-async`, opts),
6567
])
6668
.then(made => {
67-
t.strictSame(made, [
69+
t.strictSame(made.map(m => s(m)), [
6870
`${dir}/a/async`,
6971
`${dir}/a/manual-async`,
7072
doNative && `${dir}/a/native-async`,

0 commit comments

Comments
 (0)