Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI
on:
push:
branches: [ main ]
pull_request:

jobs:
pre-commit-checks:
name: "Linux - pre-commit checks"
timeout-minutes: 30
runs-on: ubuntu-latest
env:
PRE_COMMIT_USE_MICROMAMBA: 1
steps:
- name: Checkout branch
uses: actions/checkout@v3.5.2
- name: Set up micromamba
uses: mamba-org/setup-micromamba@d05808540d968a55ca33c798e0661fb98f533c73
with:
micromamba-version: 1.5.10-0
- name: Add micromamba to GITHUB_PATH
run: echo "${HOME}/micromamba-bin" >> "$GITHUB_PATH"
- name: Install Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Run pre-commit checks
uses: pre-commit/action@v3.0.0
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: pretty-format-json
args:
- "--autofix"
- "--indent=4"
- "--no-sort-keys"
- "--no-ensure-ascii"
20 changes: 18 additions & 2 deletions R/utils-file.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ user_config_path <- function() {
config_paths <- function() c(user_config_path(), default_config_path())

#' @param name File name of the configuration file (`.json` will be appended)
#' or name of a folder containing multiple configuration files.
#' @param cfg_dirs Character vector of directories searched for config files
#' @param combine_fun If multiple files are found, a function for combining
#' returned lists
Expand All @@ -275,8 +276,23 @@ get_config <- function(name, cfg_dirs = config_paths(), combine_fun = c, ...) {
assert_that(is.string(name), has_length(cfg_dirs), all_fun(cfg_dirs, is.dir),
null_or(combine_fun, is.function))

res <- lapply(file.path(cfg_dirs, paste0(name, ".json")),
read_if_exists, ...)
res <- list()

for (dir in cfg_dirs) {
dir_json <- file.path(dir, paste0(name, ".json"))
if (isTRUE(file.exists(dir_json))) {
res <- append(res, list(read_if_exists(dir_json, ...)))
}

if (isTRUE(dir.exists(file.path(dir, name)))) {
for (dir_json in list.files(path = file.path(dir, name),
pattern = "\\.json$",
full.names = TRUE,
recursive = TRUE)) {
res <- append(res, list(read_if_exists(dir_json, ...)))
}
}
}

if (is.null(combine_fun)) {
res
Expand Down
Loading
Loading