Update shell scripts

This commit is contained in:
Sander Declerck 2025-11-28 16:51:39 +01:00
parent 3af8b694fe
commit edec6ec57c
No known key found for this signature in database
7 changed files with 50 additions and 44 deletions

View file

@ -15,17 +15,17 @@ jobs:
- os: macos - os: macos
arch: x64 arch: x64
runner: macos-15-intel runner: macos-15-intel
target: node24-macos-x64 target: node20-macos-x64
extension: "" extension: ""
- os: macos - os: macos
arch: arm64 arch: arm64
runner: macos-latest runner: macos-latest
target: node24-macos-arm64 target: node20-macos-arm64
extension: "" extension: ""
- os: linux - os: linux
arch: x64 arch: x64
runner: ubuntu-latest runner: ubuntu-latest
target: node24-linux-x64 target: node20-linux-x64
extension: "" extension: ""
- os: linux - os: linux
arch: arm64 arch: arm64
@ -35,12 +35,12 @@ jobs:
- os: win - os: win
arch: x64 arch: x64
runner: windows-latest runner: windows-latest
target: node24-win-x64 target: node20-win-x64
extension: ".exe" extension: ".exe"
- os: win - os: win
arch: arm64 arch: arm64
runner: windows-11-arm runner: windows-11-arm
target: node24-win-arm64 target: node20-win-arm64
extension: ".exe" extension: ".exe"
steps: steps:
@ -50,7 +50,7 @@ jobs:
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: "24.x" node-version: "20.x"
- name: Setup safe-chain - name: Setup safe-chain
run: | run: |

View file

@ -1,3 +1,5 @@
set -gx PATH $PATH $HOME/.safe-chain/bin
function printSafeChainWarning function printSafeChainWarning
set original_cmd $argv[1] set original_cmd $argv[1]
@ -17,41 +19,40 @@ end
function wrapSafeChainCommand function wrapSafeChainCommand
set original_cmd $argv[1] set original_cmd $argv[1]
set aikido_cmd $argv[2] set cmd_args $argv[2..-1]
set cmd_args $argv[3..-1]
if type -q $aikido_cmd if type -q safe-chain
# If the aikido command is available, just run it with the provided arguments # If the safe-chain command is available, just run it with the provided arguments
$aikido_cmd $cmd_args safe-chain $original_cmd $cmd_args
else else
# If the aikido command is not available, print a warning and run the original command # If the safe-chain command is not available, print a warning and run the original command
printSafeChainWarning $original_cmd printSafeChainWarning $original_cmd
command $original_cmd $cmd_args command $original_cmd $cmd_args
end end
end end
function npx function npx
wrapSafeChainCommand "npx" "aikido-npx" $argv wrapSafeChainCommand "npx" $argv
end end
function yarn function yarn
wrapSafeChainCommand "yarn" "aikido-yarn" $argv wrapSafeChainCommand "yarn" $argv
end end
function pnpm function pnpm
wrapSafeChainCommand "pnpm" "aikido-pnpm" $argv wrapSafeChainCommand "pnpm" $argv
end end
function pnpx function pnpx
wrapSafeChainCommand "pnpx" "aikido-pnpx" $argv wrapSafeChainCommand "pnpx" $argv
end end
function bun function bun
wrapSafeChainCommand "bun" "aikido-bun" $argv wrapSafeChainCommand "bun" $argv
end end
function bunx function bunx
wrapSafeChainCommand "bunx" "aikido-bunx" $argv wrapSafeChainCommand "bunx" $argv
end end
function npm function npm
@ -66,27 +67,28 @@ function npm
end end
end end
wrapSafeChainCommand "npm" "aikido-npm" $argv wrapSafeChainCommand "npm" $argv
end end
function pip function pip
wrapSafeChainCommand "pip" "aikido-pip" $argv wrapSafeChainCommand "pip" $argv
end end
function pip3 function pip3
wrapSafeChainCommand "pip3" "aikido-pip3" $argv wrapSafeChainCommand "pip3" $argv
end end
function uv function uv
wrapSafeChainCommand "uv" "aikido-uv" $argv wrapSafeChainCommand "uv" $argv
end end
# `python -m pip`, `python -m pip3`. # `python -m pip`, `python -m pip3`.
function python function python
wrapSafeChainCommand "python" "aikido-python" $argv wrapSafeChainCommand "python" $argv
end end
# `python3 -m pip`, `python3 -m pip3'. # `python3 -m pip`, `python3 -m pip3'.
function python3 function python3
wrapSafeChainCommand "python3" "aikido-python3" $argv wrapSafeChainCommand "python3" $argv
end end

View file

@ -1,3 +1,4 @@
export PATH="$PATH:$HOME/.safe-chain/bin"
function printSafeChainWarning() { function printSafeChainWarning() {
# \033[43;30m is used to set the background color to yellow and text color to black # \033[43;30m is used to set the background color to yellow and text color to black
@ -9,15 +10,10 @@ function printSafeChainWarning() {
function wrapSafeChainCommand() { function wrapSafeChainCommand() {
local original_cmd="$1" local original_cmd="$1"
local aikido_cmd="$2"
# Remove the first 2 arguments (original_cmd and aikido_cmd) from $@ if command -v safe-chain > /dev/null 2>&1; then
# so that "$@" now contains only the arguments passed to the original command
shift 2
if command -v "$aikido_cmd" > /dev/null 2>&1; then
# If the aikido command is available, just run it with the provided arguments # If the aikido command is available, just run it with the provided arguments
"$aikido_cmd" "$@" safe-chain "$@"
else else
# If the aikido command is not available, print a warning and run the original command # If the aikido command is not available, print a warning and run the original command
printSafeChainWarning "$original_cmd" printSafeChainWarning "$original_cmd"
@ -27,27 +23,27 @@ function wrapSafeChainCommand() {
} }
function npx() { function npx() {
wrapSafeChainCommand "npx" "aikido-npx" "$@" wrapSafeChainCommand "npx" "$@"
} }
function yarn() { function yarn() {
wrapSafeChainCommand "yarn" "aikido-yarn" "$@" wrapSafeChainCommand "yarn" "$@"
} }
function pnpm() { function pnpm() {
wrapSafeChainCommand "pnpm" "aikido-pnpm" "$@" wrapSafeChainCommand "pnpm" "$@"
} }
function pnpx() { function pnpx() {
wrapSafeChainCommand "pnpx" "aikido-pnpx" "$@" wrapSafeChainCommand "pnpx" "$@"
} }
function bun() { function bun() {
wrapSafeChainCommand "bun" "aikido-bun" "$@" wrapSafeChainCommand "bun" "$@"
} }
function bunx() { function bunx() {
wrapSafeChainCommand "bunx" "aikido-bunx" "$@" wrapSafeChainCommand "bunx" "$@"
} }
function npm() { function npm() {
@ -58,27 +54,28 @@ function npm() {
return return
fi fi
wrapSafeChainCommand "npm" "aikido-npm" "$@" wrapSafeChainCommand "npm" "$@"
} }
function pip() { function pip() {
wrapSafeChainCommand "pip" "aikido-pip" "$@" wrapSafeChainCommand "pip" "$@"
} }
function pip3() { function pip3() {
wrapSafeChainCommand "pip3" "aikido-pip3" "$@" wrapSafeChainCommand "pip3" "$@"
} }
function uv() { function uv() {
wrapSafeChainCommand "uv" "aikido-uv" "$@" wrapSafeChainCommand "uv" "$@"
} }
# `python -m pip`, `python -m pip3`. # `python -m pip`, `python -m pip3`.
function python() { function python() {
wrapSafeChainCommand "python" "aikido-python" "$@" wrapSafeChainCommand "python" "$@"
} }
# `python3 -m pip`, `python3 -m pip3'. # `python3 -m pip`, `python3 -m pip3'.
function python3() { function python3() {
wrapSafeChainCommand "python3" "aikido-python3" "$@" wrapSafeChainCommand "python3" "$@"
} }

View file

@ -1,3 +1,5 @@
$env:PATH = "$env:PATH;$HOME/.safe-chain/bin"
function Write-SafeChainWarning { function Write-SafeChainWarning {
param([string]$Command) param([string]$Command)

View file

@ -1,3 +1,5 @@
set -gx PATH $PATH $HOME/.safe-chain/bin
function printSafeChainWarning function printSafeChainWarning
set original_cmd $argv[1] set original_cmd $argv[1]

View file

@ -1,3 +1,4 @@
export PATH="$PATH:$HOME/.safe-chain/bin"
function printSafeChainWarning() { function printSafeChainWarning() {
# \033[43;30m is used to set the background color to yellow and text color to black # \033[43;30m is used to set the background color to yellow and text color to black

View file

@ -1,3 +1,5 @@
$env:PATH = "$env:PATH;$HOME/.safe-chain/bin"
function Write-SafeChainWarning { function Write-SafeChainWarning {
param([string]$Command) param([string]$Command)