Skip to content

Commit

Permalink
refactor: improve link path
Browse files Browse the repository at this point in the history
In previous implementations, the result obtained from `path.relative(realSrcPath, target)` is likely to be `../../../../../../../../../var/`.
Although it has been tested and does not affect the program's execution, it looks very messy.
To avoid this issue, modify `realSrcPath` to `this.src`.

Signed-off-by: Kevin Cui <[email protected]>
  • Loading branch information
BlackHole1 committed Mar 28, 2024
1 parent 880d020 commit ad7d2d5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Filesystem {
if (relativePath.startsWith('..')) {
throw new Error(`${p}: file "${relativePath}" links out of the package`)
}
const link = path.relative(realSrcPath, target)
const link = path.relative(this.src, target)
const node = this.searchNodeFromPath(p)
node.link = link
return link
Expand Down

0 comments on commit ad7d2d5

Please sign in to comment.