| 1 |
# Turn off the default cache until the calling function exits; when that |
| 2 |
# happens, the previous default cache will be restored. |
| 3 |
local_disable_cache <- function(env = parent.frame()) { |
| 4 |
old_opts <- options(sass.cache = FALSE) |
| 5 |
withr::defer( |
| 6 |
options(old_opts), |
| 7 |
envir = env |
| 8 |
) |
| 9 |
} |
| 10 |
|
| 11 |
# Creates a temporary cache that is used as the default. When the calling |
| 12 |
# function exits, the temporary cache is destroyed, and the previous default |
| 13 |
# cache is restored. |
| 14 |
local_temp_cache <- function(env = parent.frame()) { |
| 15 |
temp_cache <- sass_file_cache(dir = tempfile()) |
| 16 |
old_opts <- options(sass.cache = temp_cache) |
| 17 |
withr::defer( |
| 18 |
{ |
| 19 |
options(old_opts) |
| 20 |
temp_cache$destroy() |
| 21 |
}, |
| 22 |
envir = env |
| 23 |
) |
| 24 |
} |