Skip to content

Commit

Permalink
fix: worka around issue with processx on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilzyla committed Oct 7, 2024
1 parent 09b60f1 commit 08df826
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions R/node.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,29 @@ node_init <- function(npm_command) {

# Run the specified command in Node.js directory (assume it already exists).
node_run <- function(command, ..., background = FALSE) {
args <- list(
command = command,
args = rlang::chr(...),
if (.Platform$OS.type == "windows") {
# Workaround: {processx} cannot find `npm` on Windows, but it works with a shell.
call_args <- list(
command = "cmd",
args = rlang::chr("/c", command, ...)
)
} else {
call_args <- list(
command = command,
args = rlang::chr(...)
)
}
call_args <- c(
call_args,
wd = node_path(),
stdin = NULL,
stdout = "",
stderr = ""
)
if (background) {
do.call(processx::process$new, args)
do.call(processx::process$new, call_args)
} else {
do.call(processx::run, args)
do.call(processx::run, call_args)
invisible()
}
}

0 comments on commit 08df826

Please sign in to comment.