Skip to content

Commit

Permalink
extractInstallPkg can now deal with require() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
al2na committed Dec 21, 2023
1 parent 7cab7f8 commit 18c8678
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions R/extractInstallPkg.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,10 @@ extractInstallPkg<-function(code){
# For each line look for library call and install things if not installed
for(a in 1:length(code_lines)){

if(grepl("library\\(", code_lines[a])){
new_code <- gsub("library\\((.*)\\)", "check_install('\\1')", code_lines[a])
if(grepl("(install|require)\\(", code_lines[a])){
new_code <- gsub("(install|require)\\((.*)\\)", "check_install('\\2')", code_lines[a])
message("trying to install ",new_code,"\n")
eval(str2expression(new_code)) # Execute install code

}
}
}

0 comments on commit 18c8678

Please sign in to comment.