Skip to content

Commit

Permalink
🤷🏻‍♂️
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarber623-cargosense committed Feb 29, 2024
1 parent db0eb35 commit d10303d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/shellcheck/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
],
"default": "os-provided",
"description": "Select or enter a ShellCheck version."
},
"installPath": {
"type": "string",
"default": "/usr/local/bin",
"description": "The path where ShellCheck will be installed."
}
},
"installsAfter": [
Expand Down
10 changes: 5 additions & 5 deletions src/shellcheck/install.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

set -e

SHELLCHECK_VERSION="${VERSION:-"os-provided"}"
INSTALL_PATH="${INSTALLPATH:-"/usr/local/bin"}"

if [[ "$(id -u)" -ne 0 ]]; then
if [ "$(id -u)" -ne 0 ]; then
printf 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi


if [[ "${SHELLCHECK_VERSION}" = "os-provided" ]]; then
if [ "${SHELLCHECK_VERSION}" = "os-provided" ]; then
apt update --yes
apt install --no-install-recommends --yes shellcheck

Expand All @@ -27,7 +27,7 @@ if ! type curl >/dev/null 2>&1; then
curl_installed="true"
fi

if [[ "${SHELLCHECK_VERSION}" = "latest" ]]; then
if [ "${SHELLCHECK_VERSION}" = "latest" ]; then
SHELLCHECK_VERSION="$(curl -s --head https://github.com/koalaman/shellcheck/releases/latest | sed -nr 's/location:.*\/v(.+)/\1/ip' | tr -d '\r')"
fi

Expand All @@ -47,6 +47,6 @@ url="https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERS

curl -sSL "${url}" | tar --strip-components=1 -Jxvf - -C "${INSTALL_PATH}" "shellcheck-v${SHELLCHECK_VERSION}/shellcheck"

if [[ -n "${curl_installed}" ]]; then
if [ -n "${curl_installed}" ]; then
apt purge curl --autoremove --yes
fi
6 changes: 3 additions & 3 deletions test/shellcheck/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"shellcheck-version": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"image": "debian:latest",
"features": {
"shellcheck": {
"version": "0.7.0"
"version": "0.8.0"
}
}
},

"shellcheck-install-path": {
"image": "mcr.microsoft.com/devcontainers/base:debian",
"image": "debian:latest",
"features": {
"shellcheck": {
"installPath": "/usr/bin"
Expand Down
2 changes: 1 addition & 1 deletion test/shellcheck/shellcheck-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ source dev-container-features-test-lib
# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "version" bash -c "shellcheck --version | grep 0.7.0"
check "version" bash -c "shellcheck --version | grep 0.8.0"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
Expand Down

0 comments on commit d10303d

Please sign in to comment.