Skip to content

Commit fba2865

Browse files
committed
fix: make filePaths platform agnostic
Use `path.sep` as the file separator instead of `/` so that this works on both Windows and Unix. Rename input parameter from `path` to `modulePath` so that it doesn't override `node:path`
1 parent 7d2642d commit fba2865

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ const isFile = (path?: string | undefined): path is string => {
250250
}
251251
}
252252

253-
const isModule = (path?: string | undefined): path is string => {
254-
return !!path && isFile(`${path}/package.json`)
253+
const isModule = (modulePath?: string | undefined): modulePath is string => {
254+
return !!modulePath && isFile(`${modulePath}${path.sep}package.json`)
255255
}
256256

257257
/**
@@ -287,7 +287,7 @@ function getMappedPath(
287287
]),
288288
)
289289
.flat(2)
290-
.filter(path => isFile(path) || isModule(path))
290+
.filter(mappedPath => isFile(mappedPath) || isModule(mappedPath))
291291
}
292292

293293
if (retry && paths.length === 0) {

0 commit comments

Comments
 (0)