diff --git a/src/scripts/tools/add_tools.ps1 b/src/scripts/tools/add_tools.ps1 index a3b7a739..127b9c6c 100644 --- a/src/scripts/tools/add_tools.ps1 +++ b/src/scripts/tools/add_tools.ps1 @@ -23,7 +23,6 @@ Function Edit-ComposerConfig() { Set-Content -Path $composer_json -Value "{}" } Add-EnvPATH $src\configs\composer.env - Add-Path $composer_bin if (Test-Path env:COMPOSER_TOKEN) { Add-Env COMPOSER_AUTH ('{"github-oauth": {"github.com": "' + $env:COMPOSER_TOKEN + '"}}') } @@ -176,6 +175,7 @@ Function Add-ComposertoolHelper() { Remove-Item -Path $composer_lock -Force } composer global require $prefix$release $composer_args >$null 2>&1 + Add-Path $composer_bin return composer global show $prefix$tool 2>&1 | findstr '^versions' } else { $release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release)) diff --git a/src/scripts/tools/add_tools.sh b/src/scripts/tools/add_tools.sh index e0900541..bcc2b7d9 100644 --- a/src/scripts/tools/add_tools.sh +++ b/src/scripts/tools/add_tools.sh @@ -43,7 +43,6 @@ configure_composer() { chmod 644 "$composer_json" fi add_env_path "${src:?}"/configs/composer.env - add_path "$composer_bin" if [ -n "$COMPOSER_TOKEN" ]; then add_env COMPOSER_AUTH '{"github-oauth": {"github.com": "'"$COMPOSER_TOKEN"'"}}' fi @@ -138,6 +137,7 @@ add_composertool_helper() { sudo rm -f "$composer_lock" >/dev/null 2>&1 || true composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1 composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1 + add_path "$composer_bin" else scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)" if ! [ -d "$scoped_dir" ]; then diff --git a/src/scripts/unix.sh b/src/scripts/unix.sh index a6ee32c9..ae89ba8d 100644 --- a/src/scripts/unix.sh +++ b/src/scripts/unix.sh @@ -99,7 +99,7 @@ get_shell_profile() { # Function to add a path to the PATH variable. add_path() { path_to_add=$1 - [ ! -d "$path_to_add" ] && [[ ":$PATH:" == *":$path_to_add:"* ]] && return + { [ ! -d "$path_to_add" ] || [[ ":$PATH:" == *":$path_to_add:"* ]]; } && return if [[ -n "$GITHUB_PATH" ]]; then echo "$path_to_add" | tee -a "$GITHUB_PATH" >/dev/null 2>&1 else