Code Quality

This commit is contained in:
Reinier Criel 2026-04-13 14:40:42 -07:00
parent 1076d6bea8
commit e54869ddd0
4 changed files with 16 additions and 17 deletions

View file

@ -38,7 +38,7 @@ function Test-InstallDir {
} }
$Version = $env:SAFE_CHAIN_VERSION # Will be fetched from latest release if not set $Version = $env:SAFE_CHAIN_VERSION # Will be fetched from latest release if not set
$SafeChainBase = if ($InstallDir) { $InstallDir } else { Join-Path $env:USERPROFILE ".safe-chain" } $SafeChainBase = if ($InstallDir) { $InstallDir } else { Join-Path $HOME ".safe-chain" }
$installDirValidation = Test-InstallDir -Dir $SafeChainBase $installDirValidation = Test-InstallDir -Dir $SafeChainBase
if (-not $installDirValidation.Ok) { if (-not $installDirValidation.Ok) {

View file

@ -5,6 +5,10 @@
# Function to remove shim from PATH (POSIX-compliant) # Function to remove shim from PATH (POSIX-compliant)
remove_shim_from_path() { remove_shim_from_path() {
_safe_chain_shims=$(CDPATH= cd -- "$(dirname -- "$0")" 2>/dev/null && pwd -P) _safe_chain_shims=$(CDPATH= cd -- "$(dirname -- "$0")" 2>/dev/null && pwd -P)
if [ -z "$_safe_chain_shims" ]; then
echo "$PATH"
return
fi
echo "$PATH" | sed "s|${_safe_chain_shims}:||g" echo "$PATH" | sed "s|${_safe_chain_shims}:||g"
} }

View file

@ -1,5 +1,6 @@
set -l safe_chain_script (status filename) set -l safe_chain_script (status filename)
set -l safe_chain_base (path dirname (path dirname $safe_chain_script)) set -l safe_chain_scripts_dir (dirname $safe_chain_script)
set -l safe_chain_base (dirname $safe_chain_scripts_dir)
set -gx PATH $PATH $safe_chain_base/bin set -gx PATH $PATH $safe_chain_base/bin
function npx function npx

View file

@ -1,18 +1,12 @@
_get_safe_chain_script_path() { if [ -n "${BASH_SOURCE[0]:-}" ]; then
if [ -n "${BASH_SOURCE[0]:-}" ]; then _sc_script_path="${BASH_SOURCE[0]}"
printf '%s\n' "${BASH_SOURCE[0]}" elif [ -n "${ZSH_VERSION:-}" ]; then
return # ${(%):-%x} uses Zsh prompt expansion to get the sourced file's path.
fi # eval is required so other shells don't try to parse the Zsh-specific syntax.
eval '_sc_script_path="${(%):-%x}"'
if [ -n "${ZSH_VERSION:-}" ]; then else
eval 'printf "%s\n" "${(%):-%x}"' _sc_script_path="$0"
return fi
fi
printf '%s\n' "$0"
}
_sc_script_path="$(_get_safe_chain_script_path)"
_sc_scripts_dir=$(CDPATH= cd -- "$(dirname -- "$_sc_script_path")" 2>/dev/null && pwd -P) _sc_scripts_dir=$(CDPATH= cd -- "$(dirname -- "$_sc_script_path")" 2>/dev/null && pwd -P)
_sc_base=$(dirname -- "$_sc_scripts_dir") _sc_base=$(dirname -- "$_sc_scripts_dir")
export PATH="$PATH:${_sc_base}/bin" export PATH="$PATH:${_sc_base}/bin"