Skip to contents

Build directory structure from a configuration file

Usage

build_from_config(config, root = NULL)

Arguments

config

configuration object from config::get() containing paths#'

root

root directory to build from. Leave as NULL if using absolute paths. Set to working directory if using relative paths.

Value

Called for its side-effects. The directories build print as a tree-like format from fs::dir_tree().

Examples

tmpdir <- tempdir()

hierarchy <- "default:
  paths:
    data: !expr list(DEV = '/demo/DEV/username/project1/data',
                     PROD = '/demo/PROD/project1/data')
    output: !expr list(DEV = '/demo/DEV/username/project1/output',
                       PROD = '/demo/PROD/project1/output')
    programs: !expr list(DEV = '/demo/DEV/username/project1/programs',
                         PROD = '/demo/PROD/project1/programs')
    docs: !expr list(DEV = 'docs',
                     PROD = 'docs')"

writeLines(hierarchy, file.path(tmpdir, "hierarchy.yml"))

config <- config::get(file = file.path(tmpdir, "hierarchy.yml"))

build_from_config(config, tmpdir)
#>  Directories built
#> /tmp/Rtmp4W5uPx
#> ├── bslib-20fbd66971b884057e0f6b3d0970a7b1
#> ├── demo
#> │   ├── DEV
#> │   │   └── username
#> │   │       └── project1
#> │   │           ├── data
#> │   │           ├── output
#> │   │           └── programs
#> │   └── PROD
#> │       └── project1
#> │           ├── data
#> │           ├── output
#> │           └── programs
#> ├── docs
#> ├── downlit
#> └── filebd0a40f64980
#>     ├── devel
#>     │   ├── articles
#>     │   ├── deps
#>     │   │   ├── bootstrap-5.2.2
#>     │   │   └── jquery-3.6.0
#>     │   ├── news
#>     │   └── reference
#>     │       └── figures
#>     └── main
#>         ├── deps
#>         │   ├── bootstrap-5.2.2
#>         │   └── jquery-3.6.0
#>         └── reference
#>             └── figures