Skip to content

Commit 1389c44

Browse files
committed
feat: add shell of startup install mage.
1 parent a454b4f commit 1389c44

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

bootstrap_install_mage.bat

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@echo off
2+
SETLOCAL
3+
4+
mage -version >nul 2>&1
5+
IF %ERRORLEVEL% EQU 0 (
6+
echo Mage is already installed.
7+
GOTO DOWNLOAD
8+
)
9+
10+
go version >nul 2>&1
11+
IF NOT %ERRORLEVEL% EQU 0 (
12+
echo Go is not installed. Please install Go and try again.
13+
exit /b 1
14+
)
15+
16+
echo Installing Mage...
17+
go install github.com/magefile/mage@latest
18+
19+
mage -version >nul 2>&1
20+
IF NOT %ERRORLEVEL% EQU 0 (
21+
echo Mage installation failed.
22+
echo Please ensure that %GOPATH%/bin is in your PATH.
23+
exit /b 1
24+
)
25+
26+
echo Mage installed successfully.
27+
28+
:DOWNLOAD
29+
go mod download
30+
31+
ENDLOCAL

bootstrap_install_mage.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
if [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
4+
TARGET_DIR="$HOME/.local/bin"
5+
else
6+
TARGET_DIR="/usr/local/bin"
7+
echo "Using /usr/local/bin as the installation directory. Might require sudo permissions."
8+
fi
9+
10+
if ! command -v mage &> /dev/null; then
11+
echo "Installing Mage to $TARGET_DIR ..."
12+
GOBIN=$TARGET_DIR go install github.com/magefile/mage@latest
13+
fi
14+
15+
if ! command -v mage &> /dev/null; then
16+
echo "Mage installation failed."
17+
echo "Please ensure that $TARGET_DIR is in your \$PATH."
18+
exit 1
19+
fi
20+
21+
echo "Mage installed successfully."
22+
23+
go mod download

0 commit comments

Comments
 (0)