Skip to content

Commit

Permalink
[r-packages] allow whitespace in packages (#207)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpprdan committed Nov 16, 2023
1 parent cd2528c commit f9e426d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/r-packages/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/r-packages/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions test/apt-packages/install-curl-nano-wget-ws.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions test/apt-packages/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 13 additions & 0 deletions test/r-packages/install-cli-rlang-ws.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions test/r-packages/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit f9e426d

Please sign in to comment.