Apply a hotfix file and inject the patch definitions

apply_hotfix_file(file, pkg = NULL)

Arguments

file

Path to an R script that defines `patch_list` and optionally `pkg`.

pkg

Optional package name if not provided in the script.

Value

Invisibly TRUE on success.

Examples

# Create a temporary hotfix file
hotfix_content <- "
pkg <- 'hotpatchR'
patch_list <- list(
  dummy_child_func = function(x) {
    paste('HOTFIXED! Input:', x)
  }
)
"

hotfix_file <- tempfile(fileext = ".R")
writeLines(hotfix_content, hotfix_file)

# Apply the hotfix from file
apply_hotfix_file(file = hotfix_file, pkg = "hotpatchR")
#> Successfully applied hotfix to package: hotpatchR

# Verify the patch works
result <- dummy_parent_func("test")
print(result)
#> [1] "Parent output -> HOTFIXED! Input: test"

# Clean up
unlink(hotfix_file)