fix: ensure paths start with a leading slash in withRepo function

This commit is contained in:
purocean
2025-01-27 21:25:00 +08:00
parent 22d1b9ed8d
commit c65f6fa05f
+5
View File
@@ -82,6 +82,11 @@ function withRepo<T> (repo = 'main', callback: (repoPath: string, ...targetPath:
}
return callback(repoPath, ...target.map(x => {
// fix path
if (!x.startsWith('/')) {
x = '/' + x
}
const targetPath = isRootRepo
? x.replace(/^\//, repoPath) // replace first / to repoPath for case of `\\127.0.0.1/test/a.md`
: path.join(repoPath, x)