routify
routify copied to clipboard
Ignore patterns vs dangling symlinks
Emacs by default uses dangling symbolic links to guard against accidentally editing the same file from two editors: https://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html
In practice, this looks like
$ find -name '.#*' -ls
6017389 4 lrwxrwxrwx 1 tv tv 22 Aug 26 09:02 ./src/pages/test/.#foo.svelte -> [email protected]:1597784741
Since these symlinks have the same extension as the original file, they have a long history of triggering bugs in programs that either don't filter out hidden files, or just get very confused about seeing danling symlinks.
This causes routify
to log errors like
[Routify] ✖ Failed to watch pages directory [Error: ENOENT: no such file or directory, stat 'src/pages/project/[project]/.#domains.svelte'] {
errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: 'src/pages/project/[project]/.#domains.svelte'
}
(node:68) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat '/src/src/pages/project/[project]/.#domains.svelte'
and it seems ignore patterns are not used for watching files:
$ cat routify.config.js
module.exports = {
routifyDir: "_routify",
ignore: "**/.#*",
}
Things that could be improved:
-
ignore
config is undocumented and assumes user just knows what's acceptable. The docs don't even say it's a glob pattern. -
Watch functionality should obey ignore too.
-
lib/middleware/generateFileTree.js
isAcceptedDir
seems to already filter out leading underscores, it could filter out leading.
too. -
Based on a quick read,
lib/middleware/generateFileTree.js
applies the filterisIgnored
too late; by the timeisIgnored
is used, the file has already been stat(2)'ed (isDirectory
). -
Same as above, it seems
isIgnored
doesn't apply to the else branch ofif (isDir)
at all.