-
Notifications
You must be signed in to change notification settings - Fork 38
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
cli: search for the tree root by default #309
Conversation
Restore the treefmt 1.x behaviour where it would search for the tree root by recursively searching for the treefmt.toml file up the filesystem, starting from the current directory. The `--tree-root-file` option will be useful to remove this bash wrapper: https://github.com/numtide/treefmt-nix/blob/2fba33a182602b9d49f0b2440513e5ee091d838b/module-options.nix#L116-L135 Fixes #308
for _, dir := range eachDir(searchDir) { | ||
path := filepath.Join(dir, fileName) | ||
if fileExists(path) { | ||
return path, dir, nil |
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.
how does this handle symlinks? Would it follow a directory symlink that might "escape" into a completely different directory tree?
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.
eachDir is only decomposing the /path/ string, removing one component after the other. I don't like to follow symlinks because it can lead to infinite loops and other weirdnesses.
fileExists will return true if the file is readable. It can be a symlink to another file, that's fine.
Co-authored-by: Brian McGee <[email protected]>
kong resolves path types to absolute paths
@mergify queue |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 2454542 |
Restore the treefmt 1.x behaviour where it would search for the tree root by recursively searching for the treefmt.toml file up the filesystem, starting from the current directory.
The
--tree-root-file
option will be useful to remove this bash wrapper: https://github.com/numtide/treefmt-nix/blob/2fba33a182602b9d49f0b2440513e5ee091d838b/module-options.nix#L116-L135Fixes #308