Skip to content

Commit 306016b

Browse files
authored
Add DevTool to PATH during install (#44)
* Add DevTool to PATH during install This is so that it will be on PATH for the initial Terminal that is launched in a new Codespace
1 parent 2eca587 commit 306016b

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/devtool/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "DevTool",
33
"id": "devtool",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"description": "Install DevTool",
66
"installsAfter": [
77
"ghcr.io/devcontainers/features/common-utils"

src/devtool/install.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,33 @@ EOF
4949
tee -a "$DEVTOOL_SCRIPT_PATH" > /dev/null \
5050
<< 'EOF'
5151
52-
echo "Installing DevTool..."
52+
echo "::step::Waiting for AzDO Authentication Helper..."
5353
# Wait up to 3 minutes for the ado-auth-helper to be installed
5454
for i in {1..180}; do
5555
if [ -f ${HOME}/ado-auth-helper ]; then
5656
break
5757
fi
5858
sleep 1
5959
done
60-
60+
echo "::step::Installing DevTool..."
6161
cd /tmp
6262
curl -sL https://aka.ms/InstallToolLinux.sh | sh -s DevTool
6363
EOF
6464

6565
chmod 755 "$DEVTOOL_SCRIPT_PATH"
6666

67+
# Setup PATH so that DevTool will be on PATH when the initial terminal is started
68+
if command -v sudo >/dev/null 2>&1; then
69+
if [ "root" != "$_REMOTE_USER" ]; then
70+
echo "Adding DevTool to PATH for $_REMOTE_USER"
71+
sudo -u ${_REMOTE_USER} bash -c 'echo "export PATH=\$PATH:$HOME/.config/DevTool/CurrentVersion" >> ~/.bashrc'
72+
sudo -u ${_REMOTE_USER} bash -c 'echo "export PATH=\$PATH:$HOME/.config/DevTool/CurrentVersion" >> ~/.zshrc'
73+
exit 0
74+
fi
75+
fi
76+
77+
echo "Adding DevTool to PATH for root"
78+
echo "export PATH=\$PATH:/root/.config/DevTool/CurrentVersion" >> /etc/bash.bashrc || true
79+
echo "export PATH=\$PATH:/root/.config/DevTool/CurrentVersion" >> /etc/zsh/zshrc || true
80+
6781
exit 0

test/devtool/test.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ set -e
66
source dev-container-features-test-lib
77

88
# Feature-specific tests
9-
check "devtool" cat /usr/local/share/install-devtool.sh
10-
9+
check "devtool" grep "DevTool" <(cat ~/.bashrc)
1110

1211
# Report results
1312
# If any of the checks above exited with a non-zero exit code, the test will fail.

0 commit comments

Comments
 (0)