Skip to content

Commit fbb429d

Browse files
committed
another try to fix the crossplatform issues
1 parent 5b0e7e7 commit fbb429d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/instanceof.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ test('ensure that instanceof works accross different installations of the fastif
9090
const { foo } = require('dep')
9191
9292
function normalizePath (filePath) {
93+
// normalize for cross platform
94+
filePath = filePath.replace(/\\\\/g, '/')
95+
filePath = filePath.replace(/(\\w):/, '/$1')
96+
filePath = filePath.replace(/(\\w+)\\/\\.\\.\\/?/g, '')
97+
filePath = filePath.replace(/^\\.\\//, '')
98+
filePath = filePath.replace(/\\/\\.\\//, '/')
99+
filePath = filePath.replace(/\\/\\.$/, '')
100+
filePath = filePath.replace(/\\/$/, '')
101+
93102
console.log('filePath', filePath)
94103
console.log('path.normalize(filePath)', path.normalize(filePath))
95104
console.log('path.normalize(filePath).lastIndexOf("${testDirectoryPrefix}")', path.normalize(filePath).lastIndexOf('${testDirectoryPrefix}'))
@@ -144,6 +153,15 @@ test('ensure that instanceof works accross different installations of the fastif
144153
const { createError } = require('fastify-error')
145154
146155
function normalizePath (filePath) {
156+
// normalize for cross platform
157+
filePath = filePath.replace(/\\\\/g, '/')
158+
filePath = filePath.replace(/(\\w):/, '/$1')
159+
filePath = filePath.replace(/(\\w+)\\/\\.\\.\\/?/g, '')
160+
filePath = filePath.replace(/^\\.\\//, '')
161+
filePath = filePath.replace(/\\/\\.\\//, '/')
162+
filePath = filePath.replace(/\\/\\.$/, '')
163+
filePath = filePath.replace(/\\/$/, '')
164+
147165
console.log('filePath', filePath)
148166
console.log('path.normalize(filePath)', path.normalize(filePath))
149167
console.log('path.normalize(filePath).lastIndexOf("${testDirectoryPrefix}")', path.normalize(filePath).lastIndexOf('${testDirectoryPrefix}'))

0 commit comments

Comments
 (0)