-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix watcher crashing in package subdirectories #67
Conversation
traverseRecursively
error message
|
||
// `parentDirectory` just returns `self` if it's `root` | ||
cwd = cwd.parentDirectory | ||
} while cwd != root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that AbsolutePath
has a property isRoot
to check whether it's a root directory.
} while cwd != root | |
} while !cwd.isRoot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, I initially wasn't sure if this property is public at all.
Co-authored-by: ninjiacoder <ninjiacoder@gmail.com>
Currently, when
carton dev
is launched in any subdirectory of the package not containingPackage.swift
it crashes. It's caused bytraverseRecursively
precondition failing when a non-directory (or non-existent) path is passed to it. I thinktraverseRecursively
can handle non-existing paths well by returning an empty array, and the path itself when it's a file and not a directory. Thus the precondition check is not needed at all.Non-existent paths were created due to a wrong assumption that the root package directory is always the current directory. This is now fixed by adding a new
inferManifestDirectory
function, which correctly calculates absolute paths of source directories before passing them to the watcher.Additionally the watcher code in the
TSCBasic
code has its own precondition for non-empty path arrays passed to it. To avoid triggering it and staying extra-safe, we check for an empty watcher paths array and avoid watching anything at all.