Skip to content

Commit e9a4222

Browse files
committed
fix: fix relative path to absolute path transformation
1 parent 4ad85e6 commit e9a4222

File tree

2 files changed

+69
-37
lines changed

2 files changed

+69
-37
lines changed

pnpm-lock.yaml

Lines changed: 65 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/util/path-util.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import path from 'path'
12
import jiti from 'jiti'
23
import upperCamelcase from 'uppercamelcase'
34

@@ -11,9 +12,11 @@ function winPath(path: string) {
1112
}
1213

1314
export function transformRelativePathToAbsPath(rPath: string, basePath = './src'): string {
15+
const joinedPath = path.join(basePath, rPath)
16+
const targetPath = joinedPath.startsWith('/') ? joinedPath : `./${joinedPath}`
1417
const absPath = jiti(process.cwd(), {
1518
extensions: ['.js', '.mjs', '.cjs', '.ts', '.jsx', '.tsx'],
16-
}).resolve(`${basePath}/${rPath}`)
19+
}).resolve(`${targetPath}`)
1720
return winPath(absPath)
1821
}
1922

0 commit comments

Comments
 (0)