Skip to content

Commit

Permalink
play nicely when using powershell and powershell-extended
Browse files Browse the repository at this point in the history
  • Loading branch information
jpawlowski committed Aug 24, 2024
1 parent d41d863 commit 47f7108
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/powershell-extended/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/powershell"
]
}
21 changes: 21 additions & 0 deletions src/powershell-extended/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,27 @@ else
echo "PowerShell is already installed."
fi

# Fix pwsh execution bit
pwsh_path=$(command -v pwsh)
if [ -L "$pwsh_path" ]; then
# get the target of the symlink
target_path=$(readlink -f "$pwsh_path")
# check if the target is a file
if [ -f "$target_path" ]; then
# check if the target is not executable
if [ ! -x "$target_path" ]; then
echo "Fixing pwsh execution bit"
chmod +x "$target_path"
fi
fi
else
# check if pwsh is not executable
if [ ! -x "$pwsh_path" ]; then
echo "Fixing pwsh execution bit"
chmod +x "$pwsh_path"
fi
fi

# Get existing repositories
IFS=';' read -r -a repos <<<"$("$(command -v pwsh)" -NoLogo -NoProfile -Command "(Get-PSResourceRepository).Uri.OriginalString -join ';'")"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# Import test library for `check` command
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Extension-specific tests
check "Az.Accounts" pwsh -Command "[string](Get-Module -ListAvailable -Name Az.Accounts -ErrorAction Stop).Version"
check "Az.Resources" pwsh -Command "[string](Get-Module -ListAvailable -Name Az.Resources -ErrorAction Stop).Version"

# Report result
reportResults
17 changes: 17 additions & 0 deletions test/powershell-extended/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@
}
}
},
"install_powershell_and_powershell-extended": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"ghcr.io/devcontainers/features/powershell:1": {
"version": "latest",
"modules": "Az.Accounts"
},
"powershell-extended": {
"resources": "Az.Resources",
"updatePSResourceGet": "none",
"updatePSReadLine": "none",
"updateModulesHelp": false,
"installOhMyPosh": false,
"installOhMyPoshConfig": false
}
}
},
"install_powershell_psconfig": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
Expand Down

0 comments on commit 47f7108

Please sign in to comment.