Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/npm-packages/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "npm-packages",
"version": "1.0.0",
"version": "1.0.1",
Comment thread
koralowiec marked this conversation as resolved.
"name": "npm-packages",
"documentationURL": "http://github.com/devcontainers-extra/features/tree/main/src/npm-packages",
"description": "",
Expand Down
15 changes: 9 additions & 6 deletions src/npm-packages/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ IFS=',' read -ra PACKAGE_ARRAY <<<"$PACKAGES"

# Iterate through each package
for package in "${PACKAGE_ARRAY[@]}"; do
# Check if package contains version
if [[ $package == *@* ]]; then
# Split package into name and version
name=${package%@*}
version=${package#*@}
# Use regex to match valid npm package identifier
# unscoped, unscoped@version, @scoped, @scoped@version
if [[ $package =~ ^(@?[^@]+?)(@(.+?))?$ ]]; then
name="${BASH_REMATCH[1]}"
version="${BASH_REMATCH[3]}"
# Bash doesn't have non-capturing groups so @version portion can
# only be made optional inside a group, then a nested group captures
# the version number itself.
else
# Package without version
# Fallback for any invalid package identifiers
name=$package
version=""
fi
Expand Down
2 changes: 1 addition & 1 deletion test/npm-packages/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"npm-packages": {
"packages": "eslint@9.20.1,nodemon,prettier@3.5.2"
"packages": "eslint@9.20.1,nodemon,prettier@3.5.2,@angular/cli@19.2.1,@biomejs/biome"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/npm-packages/test_debian_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ source dev-container-features-test-lib
check "eslint version is equal to 9.20.1" bash -c "eslint --version | grep 'v9.20.1'"
check "nodemon is installed" nodemon --version
check "prettier version is equal to 3.5.2" bash -c "prettier --version | grep '3.5.2'"
check "@angular/cli version is equal to 19.2.1" bash -c "ng --version | grep '19.2.1'"
check "@biomejs/biome is installed" biome --version

reportResults