Skip to content

Commit

Permalink
feat: add shell of startup install mage.
Browse files Browse the repository at this point in the history
  • Loading branch information
FGadvancer committed May 18, 2024
1 parent a454b4f commit 1389c44
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
31 changes: 31 additions & 0 deletions bootstrap_install_mage.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@echo off
SETLOCAL

mage -version >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
echo Mage is already installed.
GOTO DOWNLOAD
)

go version >nul 2>&1
IF NOT %ERRORLEVEL% EQU 0 (
echo Go is not installed. Please install Go and try again.
exit /b 1
)

echo Installing Mage...
go install github.com/magefile/mage@latest

mage -version >nul 2>&1
IF NOT %ERRORLEVEL% EQU 0 (
echo Mage installation failed.
echo Please ensure that %GOPATH%/bin is in your PATH.
exit /b 1
)

echo Mage installed successfully.

:DOWNLOAD
go mod download

ENDLOCAL
23 changes: 23 additions & 0 deletions bootstrap_install_mage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

if [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
TARGET_DIR="$HOME/.local/bin"
else
TARGET_DIR="/usr/local/bin"
echo "Using /usr/local/bin as the installation directory. Might require sudo permissions."
fi

if ! command -v mage &> /dev/null; then
echo "Installing Mage to $TARGET_DIR ..."
GOBIN=$TARGET_DIR go install github.com/magefile/mage@latest
fi

if ! command -v mage &> /dev/null; then
echo "Mage installation failed."
echo "Please ensure that $TARGET_DIR is in your \$PATH."
exit 1
fi

echo "Mage installed successfully."

go mod download

0 comments on commit 1389c44

Please sign in to comment.