Skip to content
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

Make dir_tree() work even when glob= or regexp= argument is supplied #442

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Feb 5, 2024

  1. Make dir_tree() work even when glob or regexp is used

    This PR addresses the issue described in r-lib#398. `dir_tree()` didn't work when a pattern was supplied to `regexp=` or `glob=` arguments that get passed on to `dir_ls()`. That's because the list of file paths returned by those calls to `dir_ls()` did not include paths of the parent (and grandparent etc.) directories that `dir_tree()` uses to construct the tree.
    
    The code I've added uses the file paths returned by `dir_ls()` to recreate the directory paths that'll be needed to build the tree.
    
    To see that this now works, try for example:
    
    ```r
    dir_tree(system.file(package = "fs"), regexp = "[.]rds$")
    dir_tree(system.file(package = "fs"), type = "directory")
    ```
    JoshOBrien committed Feb 5, 2024
    Configuration menu
    Copy the full SHA
    3dc99c0 View commit details
    Browse the repository at this point in the history
  2. Fix ordering of leafs and branches to match testthat expectations

    Files should come before directories at each level in tree. Fixed code
    to ensure that happens.
    JoshOBrien committed Feb 5, 2024
    Configuration menu
    Copy the full SHA
    427d647 View commit details
    Browse the repository at this point in the history