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/artifacts-helper/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion src/artifacts-helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/artifacts-helper/test_shim_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading