diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 9ff2ecdf..2a90b18b 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -65,6 +65,12 @@ jobs: cd RhinoApp Rscript ../test-dependencies.R + - name: Node.js commands should respect RHINO_NPM + if: always() + run: | + cd RhinoApp + Rscript ../test-custom-npm.R + - name: lint_r() should detect lint errors in R scripts if: always() run: | diff --git a/tests/e2e/test-custom-npm.R b/tests/e2e/test-custom-npm.R new file mode 100644 index 00000000..02905e4b --- /dev/null +++ b/tests/e2e/test-custom-npm.R @@ -0,0 +1,22 @@ +local({ + tmp <- withr::local_tempdir() + wrapper_path <- fs::path(tmp, "wrapper") + touch_path <- fs::path(tmp, "it_works") + + # Prepare a wrapper script which creates an "it_works" file and runs npm. + fs::file_create(wrapper_path, mode = "u=rwx") + writeLines( + c( + '#!/bin/sh', + paste('touch', touch_path), + 'exec npm "$@"' + ), + wrapper_path + ) + + # Use the wrapper script instead of npm. + withr::local_envvar(RHINO_NPM = wrapper_path) + rhino:::npm("--version") + + testthat::expect_true(fs::file_exists(touch_path)) +})