Skip to content

Commit

Permalink
fix: make filePaths platform agnostic
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
sanderson-ut committed Oct 19, 2022
1 parent 7d2642d commit fba2865
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Expand Up @@ -250,8 +250,8 @@ const isFile = (path?: string | undefined): path is string => {
}
}

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

/**
Expand Down Expand Up @@ -287,7 +287,7 @@ function getMappedPath(
]),
)
.flat(2)
.filter(path => isFile(path) || isModule(path))
.filter(mappedPath => isFile(mappedPath) || isModule(mappedPath))
}

if (retry && paths.length === 0) {
Expand Down

0 comments on commit fba2865

Please sign in to comment.