Skip to content

Commit 08df826

Browse files
committed
fix: worka around issue with processx on Windows
1 parent 09b60f1 commit 08df826

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

R/node.R

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,29 @@ node_init <- function(npm_command) {
6060

6161
# Run the specified command in Node.js directory (assume it already exists).
6262
node_run <- function(command, ..., background = FALSE) {
63-
args <- list(
64-
command = command,
65-
args = rlang::chr(...),
63+
if (.Platform$OS.type == "windows") {
64+
# Workaround: {processx} cannot find `npm` on Windows, but it works with a shell.
65+
call_args <- list(
66+
command = "cmd",
67+
args = rlang::chr("/c", command, ...)
68+
)
69+
} else {
70+
call_args <- list(
71+
command = command,
72+
args = rlang::chr(...)
73+
)
74+
}
75+
call_args <- c(
76+
call_args,
6677
wd = node_path(),
6778
stdin = NULL,
6879
stdout = "",
6980
stderr = ""
7081
)
7182
if (background) {
72-
do.call(processx::process$new, args)
83+
do.call(processx::process$new, call_args)
7384
} else {
74-
do.call(processx::run, args)
85+
do.call(processx::run, call_args)
7586
invisible()
7687
}
7788
}

0 commit comments

Comments
 (0)