Temporarily set the BRAND_YML_PATH environment variable
Source: R/with_brand_yml.R
with_brand_yml_path.RdThis function sets the BRAND_YML_PATH environment variable to the specified
path for the duration of the local environment. This ensures that, for the
scope of the local environment, any calls to functions that automatically
discover a _brand.yml file will use the path specified.
Usage
with_brand_yml_path(path, code)
local_brand_yml_path(path, .local_envir = parent.frame())Functions
with_brand_yml_path(): Run code in a temporary environment with theBRAND_YML_PATHenvironment variable set topath.local_brand_yml_path(): Set theBRAND_YML_PATHenvironment variable for the scope of the local environment (e.g. within the current function).
See also
Other brand.yml helpers:
brand_color_pluck(),
brand_has(),
brand_pluck()
Examples
# Create a temporary brand.yml file in a tempdir for this example
tmpdir <- withr::local_tempdir("brand")
path_brand <- file.path(tmpdir, "my-brand.yml")
yaml::write_yaml(
list(color = list(primary = "#abc123")),
path_brand
)
#> Warning: cannot open file '/tmp/Rtmp1nIO6F/brand1f5777eb694b/my-brand.yml': No such file or directory
#> Error in file(file, "w", encoding = fileEncoding): cannot open the connection
with_brand_yml_path(path_brand, {
brand <- read_brand_yml()
brand$color$primary
})
#> Error in as_brand_yml(path): `brand` must be a path to a brand.yml file or a string of YAML.