diff --git a/src/artifacts-helper/devcontainer-feature.json b/src/artifacts-helper/devcontainer-feature.json index d2e9441..3c8cfea 100644 --- a/src/artifacts-helper/devcontainer-feature.json +++ b/src/artifacts-helper/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Azure Artifacts Credential Helper", "id": "artifacts-helper", - "version": "3.0.6", + "version": "3.0.7", "description": "Configures Codespace to authenticate with Azure Artifact feeds", "options": { "nugetURIPrefixes": { diff --git a/src/artifacts-helper/install.sh b/src/artifacts-helper/install.sh index 87655ae..3e362da 100755 --- a/src/artifacts-helper/install.sh +++ b/src/artifacts-helper/install.sh @@ -114,6 +114,8 @@ if command -v sudo >/dev/null 2>&1; then fi fi +COMMA_SEP_TARGET_FILES="${TARGETFILES:-"DEFAULT"}" + if [ "${COMMA_SEP_TARGET_FILES}" = "DEFAULT" ]; then if [ "${INSTALL_WITH_SUDO}" = "true" ]; then COMMA_SEP_TARGET_FILES="~/.bashrc,~/.zshrc" @@ -126,7 +128,7 @@ IFS=',' read -r -a TARGET_FILES_ARR <<< "$COMMA_SEP_TARGET_FILES" ALIASES_BLOCK="" for ALIAS in "${ALIASES_ARR[@]}"; do - ALIASES_BLOCK+="$ALIAS() { \"${SHIM_DIRECTORY}/$ALIAS\" \"\$@\"; }\n" + ALIASES_BLOCK+="$ALIAS() { \"${SHIM_DIRECTORY}/$ALIAS\" \"\$@\"; }"$'\n' done for TARGET_FILE in "${TARGET_FILES_ARR[@]}"; do diff --git a/test/artifacts-helper/test_shim_integration.sh b/test/artifacts-helper/test_shim_integration.sh index f09be98..fff526a 100755 --- a/test/artifacts-helper/test_shim_integration.sh +++ b/test/artifacts-helper/test_shim_integration.sh @@ -24,5 +24,18 @@ check "npm shim sources auth-ado.sh" grep -q "source.*auth-ado.sh" /usr/local/sh # Verify the shim directory is in PATH check "shim directory in PATH" bash -c '[[ ":$PATH:" == *":/usr/local/share/codespace-shims:"* ]]' +# Verify that shell function shims are written to rc files (not just shim scripts) +check "npm shell function written to bash.bashrc" grep -q "npm()" /etc/bash.bashrc +check "dotnet shell function written to bash.bashrc" grep -q "dotnet()" /etc/bash.bashrc +check "npm shell function on its own line in bash.bashrc" grep -q "^npm()" /etc/bash.bashrc + +# Verify newlines between shim definitions (each function should be on its own line) +check "each shim function is on its own line" bash -c ' + # Count function definitions at line starts - with proper newlines each will start at column 0 + # The test_shim_integration scenario enables dotnet, npm, and nuget aliases (3 shims) + COUNT=$(grep -cE "^[a-z][-a-z]*\(\)" /etc/bash.bashrc) + [[ "$COUNT" -ge 3 ]] +' + # Report results reportResults