-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add shell of startup install mage.
- Loading branch information
1 parent
a454b4f
commit 1389c44
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |