forked from trinker/pacman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p_install_version_single.R
31 lines (27 loc) · 1.01 KB
/
p_install_version_single.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## Helper single version of p_install_version
p_install_version_single <- function(package, version){
## Determine if package is even in the users library
if (!package %in% p_lib()){
out <- p_install(package, character.only=TRUE)
if (isTRUE(out)) {
message(sprintf(
"\n%s not found in user's library; Version %s was installed",
package, utils::packageVersion(package))
)
}
return(invisible(out))
} else {
## If package is not in user's library check if version ok
if (p_ver(package) < version) {
out <- p_install(package, character.only=TRUE)
if (isTRUE(out)) {
message(sprintf("\n%s was updated to v. %s", package, p_ver(package)))
}
return(invisible(out))
} else {
message(sprintf("\nVersion of %s (v. %s) is suitable",
package, p_ver(package)))
return(invisible(TRUE))
}
}
}