Resolve symlinks for paths
This commit is contained in:
parent
14c39f4d44
commit
2102566df8
1 changed files with 19 additions and 0 deletions
|
|
@ -27,6 +27,19 @@ function parseGlob(pattern) {
|
|||
return { base, glob }
|
||||
}
|
||||
|
||||
function resolvePathSymlinks(pathDesc) {
|
||||
try {
|
||||
let newPath = fs.realpathSync(pathDesc.base, { encoding: 'utf8' })
|
||||
if (newPath !== pathDesc.base) {
|
||||
return [pathDesc, { ...pathDesc, base: newPath }]
|
||||
}
|
||||
} catch {
|
||||
// TODO: log this?
|
||||
}
|
||||
|
||||
return [pathDesc]
|
||||
}
|
||||
|
||||
function toDependency(pathDesc) {
|
||||
if (!pathDesc.glob) {
|
||||
return {
|
||||
|
|
@ -77,5 +90,11 @@ export default function parseDependency(context, normalizedFileOrGlob) {
|
|||
})
|
||||
)
|
||||
|
||||
// Resolve the symlink for the base directory / file in each path
|
||||
// These are added as additional dependencies to watch for changes because
|
||||
// some tools (like webpack) will only watch the actual file or directory
|
||||
// but not the symlink itself even in projects that use monorepos.
|
||||
paths = paths.flatMap(resolvePathSymlinks)
|
||||
|
||||
return paths.map(toDependency)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue