Build directory structure from a configuration file
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/RtmpKPwpGu
#> ├── bslib-38daeaf16d079113fb4efdfca8aab090
#> ├── demo
#> │ ├── DEV
#> │ │ └── username
#> │ │ └── project1
#> │ │ ├── data
#> │ │ ├── output
#> │ │ └── programs
#> │ └── PROD
#> │ └── project1
#> │ ├── data
#> │ ├── output
#> │ └── programs
#> ├── docs
#> ├── downlit
#> └── filebc432e8bba18
#> ├── devel
#> │ ├── deps
#> │ │ ├── bootstrap-5.2.2
#> │ │ └── jquery-3.6.0
#> │ └── reference
#> │ └── figures
#> └── main
#> ├── articles
#> │ └── config_files
#> │ └── accessible-code-block-0.0.1
#> ├── deps
#> │ ├── bootstrap-5.2.2
#> │ └── jquery-3.6.0
#> ├── news
#> └── reference
#> └── figures