Skip to content

Commit 6b84bf5

Browse files
authored
Merge pull request #109 from microsoft/copilot/fix-install-shims-in-artifacts-helper
fix(artifacts-helper): restore shim installation into shell rc files
2 parents e48c2ff + aa85008 commit 6b84bf5

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎src/artifacts-helper/devcontainer-feature.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Azure Artifacts Credential Helper",
33
"id": "artifacts-helper",
4-
"version": "3.0.6",
4+
"version": "3.0.7",
55
"description": "Configures Codespace to authenticate with Azure Artifact feeds",
66
"options": {
77
"nugetURIPrefixes": {

‎src/artifacts-helper/install.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ if command -v sudo >/dev/null 2>&1; then
114114
fi
115115
fi
116116

117+
COMMA_SEP_TARGET_FILES="${TARGETFILES:-"DEFAULT"}"
118+
117119
if [ "${COMMA_SEP_TARGET_FILES}" = "DEFAULT" ]; then
118120
if [ "${INSTALL_WITH_SUDO}" = "true" ]; then
119121
COMMA_SEP_TARGET_FILES="~/.bashrc,~/.zshrc"
@@ -126,7 +128,7 @@ IFS=',' read -r -a TARGET_FILES_ARR <<< "$COMMA_SEP_TARGET_FILES"
126128

127129
ALIASES_BLOCK=""
128130
for ALIAS in "${ALIASES_ARR[@]}"; do
129-
ALIASES_BLOCK+="$ALIAS() { \"${SHIM_DIRECTORY}/$ALIAS\" \"\$@\"; }\n"
131+
ALIASES_BLOCK+="$ALIAS() { \"${SHIM_DIRECTORY}/$ALIAS\" \"\$@\"; }"$'\n'
130132
done
131133

132134
for TARGET_FILE in "${TARGET_FILES_ARR[@]}"; do

‎test/artifacts-helper/test_shim_integration.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,18 @@ check "npm shim sources auth-ado.sh" grep -q "source.*auth-ado.sh" /usr/local/sh
2424
# Verify the shim directory is in PATH
2525
check "shim directory in PATH" bash -c '[[ ":$PATH:" == *":/usr/local/share/codespace-shims:"* ]]'
2626

27+
# Verify that shell function shims are written to rc files (not just shim scripts)
28+
check "npm shell function written to bash.bashrc" grep -q "npm()" /etc/bash.bashrc
29+
check "dotnet shell function written to bash.bashrc" grep -q "dotnet()" /etc/bash.bashrc
30+
check "npm shell function on its own line in bash.bashrc" grep -q "^npm()" /etc/bash.bashrc
31+
32+
# Verify newlines between shim definitions (each function should be on its own line)
33+
check "each shim function is on its own line" bash -c '
34+
# Count function definitions at line starts - with proper newlines each will start at column 0
35+
# The test_shim_integration scenario enables dotnet, npm, and nuget aliases (3 shims)
36+
COUNT=$(grep -cE "^[a-z][-a-z]*\(\)" /etc/bash.bashrc)
37+
[[ "$COUNT" -ge 3 ]]
38+
'
39+
2740
# Report results
2841
reportResults

0 commit comments

Comments
 (0)