mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Code Quality
This commit is contained in:
parent
1076d6bea8
commit
e54869ddd0
4 changed files with 16 additions and 17 deletions
|
|
@ -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) {
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,12 @@
|
||||||
_get_safe_chain_script_path() {
|
|
||||||
if [ -n "${BASH_SOURCE[0]:-}" ]; then
|
if [ -n "${BASH_SOURCE[0]:-}" ]; then
|
||||||
printf '%s\n' "${BASH_SOURCE[0]}"
|
_sc_script_path="${BASH_SOURCE[0]}"
|
||||||
return
|
elif [ -n "${ZSH_VERSION:-}" ]; then
|
||||||
|
# ${(%):-%x} uses Zsh prompt expansion to get the sourced file's path.
|
||||||
|
# eval is required so other shells don't try to parse the Zsh-specific syntax.
|
||||||
|
eval '_sc_script_path="${(%):-%x}"'
|
||||||
|
else
|
||||||
|
_sc_script_path="$0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${ZSH_VERSION:-}" ]; then
|
|
||||||
eval 'printf "%s\n" "${(%):-%x}"'
|
|
||||||
return
|
|
||||||
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"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue