From f9e426dcd910923c678639a2be4514f51af2650d Mon Sep 17 00:00:00 2001 From: Daniel Possenriede Date: Thu, 16 Nov 2023 23:54:41 +0100 Subject: [PATCH] [r-packages] allow whitespace in `packages` (#207) This is a small change to allow for whitespace in the `packages` specification, so that using ```jsonc "packages": "cli, rlang" ``` does not lead to an error. --- src/r-packages/devcontainer-feature.json | 2 +- src/r-packages/install.sh | 2 +- test/apt-packages/install-curl-nano-wget-ws.sh | 14 ++++++++++++++ test/apt-packages/scenarios.json | 8 ++++++++ test/r-packages/install-cli-rlang-ws.sh | 13 +++++++++++++ test/r-packages/scenarios.json | 8 ++++++++ 6 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 test/apt-packages/install-curl-nano-wget-ws.sh create mode 100644 test/r-packages/install-cli-rlang-ws.sh diff --git a/src/r-packages/devcontainer-feature.json b/src/r-packages/devcontainer-feature.json index ecd6e21..7d0f341 100644 --- a/src/r-packages/devcontainer-feature.json +++ b/src/r-packages/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "R packages (via pak)", "id": "r-packages", - "version": "1.0.3", + "version": "1.0.4", "description": "Installs R packages via the pak R package's function. R must be already installed.", "documentationURL": "https://github.com/rocker-org/devcontainer-features/tree/main/src/r-packages", "options": { diff --git a/src/r-packages/install.sh b/src/r-packages/install.sh index b07601d..8b29892 100755 --- a/src/r-packages/install.sh +++ b/src/r-packages/install.sh @@ -92,7 +92,7 @@ install_r_packages() { fi fi - su "${USERNAME}" -c "R -q -e \"pak::repo_add(${ADDITIONAL_REPOSITORIES}); pak::pak(unlist(strsplit('${packages}', ','))); pak::cache_clean()\"" + su "${USERNAME}" -c "R -q -e \"pak::repo_add(${ADDITIONAL_REPOSITORIES}); pak::pak(trimws(unlist(strsplit('${packages}', ',')))); pak::cache_clean()\"" if [ "${is_apt}" = "true" ]; then # Clean up diff --git a/test/apt-packages/install-curl-nano-wget-ws.sh b/test/apt-packages/install-curl-nano-wget-ws.sh new file mode 100644 index 0000000..207281d --- /dev/null +++ b/test/apt-packages/install-curl-nano-wget-ws.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +# Feature-specific tests +check "curl" curl --version +check "nano" nano --version +check "wget" wget --version + +# Report result +reportResults diff --git a/test/apt-packages/scenarios.json b/test/apt-packages/scenarios.json index 9f8524f..3d36fe8 100644 --- a/test/apt-packages/scenarios.json +++ b/test/apt-packages/scenarios.json @@ -7,6 +7,14 @@ } } }, + "install-curl-nano-wget-ws": { + "image": "debian:stable-slim", + "features": { + "apt-packages": { + "packages": "curl, nano, wget" + } + } + }, "only-upgrade": { "image": "debian:stable-slim", "features": { diff --git a/test/r-packages/install-cli-rlang-ws.sh b/test/r-packages/install-cli-rlang-ws.sh new file mode 100644 index 0000000..999e609 --- /dev/null +++ b/test/r-packages/install-cli-rlang-ws.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +# Feature-specific tests +check "R cli package" R -q -e 'names(installed.packages()[, 3])' | grep cli +check "R rlang package" R -q -e 'names(installed.packages()[, 3])' | grep rlang + +# Report result +reportResults diff --git a/test/r-packages/scenarios.json b/test/r-packages/scenarios.json index bc79ea8..47d2fc2 100644 --- a/test/r-packages/scenarios.json +++ b/test/r-packages/scenarios.json @@ -7,6 +7,14 @@ } } }, + "install-cli-rlang-ws": { + "image": "rocker/r-ver:4", + "features": { + "r-packages": { + "packages": "cli, rlang" + } + } + }, "install-from-github": { "image": "rocker/r-ver:4", "features": {