is_available: Check executable availability and version

Description Usage Arguments Value Examples

View source: R/informations.R

Description

determine whether an executable is currently available on the user machine (optionally checking for a specific or greater version).

Usage

1
is_available(exec, version = NULL, error = FALSE)

Arguments

exec

executable identifier, a single character. Use one of these values:

  • chrome: "Google Chrome" executable

  • libreoffice: "LibreOffice" executable

  • node: "node.js" executable

  • npm: "npm" executable

  • python: "python" executable

  • pip: "pip" executable

version

required version of executable

error

if TRUE, executes an error action if executable with the required version is not found.

Value

a logical indicating whether the executable is available.

Examples

 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
if (is_available("python")) {
  cat("python", as.character(exec_version("python")), "is available!\\n")
}
py_path <- "~/../AppData/Local/Programs/Python/Python39"
if(dir.exists(py_path)){
  locate_exec("python", dir = py_path, cache = FALSE)
}
if(is_available("python", "3.9")) {
  cat("required version of python is available!\\n")
}
if (is_available("pip")) {
  cat("pip", as.character(exec_version("pip")), "is available!\\n")
}
if (is_available("pip", "19.3")) {
  cat("pip", as.character(exec_version("pip")), "is available!\\n")
}
if (is_available("chrome")) {
  cat("chrome", as.character(exec_version("chrome")), "is available!\\n")
}
if (is_available("node")) {
  cat("node.js", as.character(exec_version("node")), "is available!\\n")
}
if (is_available("npm")) {
  cat("npm", as.character(exec_version("npm")), "is available!\\n")
}
if (is_available("npm", version = "10.13.0")) {
  cat("npm", as.character(exec_version("npm")), "is available!\\n")
}

davidgohel/locatexec documentation built on Feb. 17, 2021, 9:46 a.m.