Skip to content

Instantly share code, notes, and snippets.

@cyberwani
Created July 27, 2024 10:27
Show Gist options
  • Save cyberwani/3f4a2b0b0ed5775a94d47e463ea6dc70 to your computer and use it in GitHub Desktop.
Save cyberwani/3f4a2b0b0ed5775a94d47e463ea6dc70 to your computer and use it in GitHub Desktop.
@echo off
:: Get the current directory
set "current_dir=%cd%"
set "wp_cli_cache=%current_dir%\cache"
:: Add the current directory to the PATH environment variable
cls
:: Check if the current directory is already in the system PATH
echo %PATH% | findstr /C:"%current_dir%" >nul
if %ERRORLEVEL% NEQ 0 (
:: Add the current directory to the system PATH environment variable
setx PATH "%PATH%;%current_dir%" /M
cls
)
setx WP_CLI_CACHE_DIR "%wp_cli_cache%" /M
:: Create wp.bat in the current directory
echo @ECHO OFF > "%current_dir%\wp.bat"
echo php "%current_dir%\wp-cli.phar" %%* >> "%current_dir%\wp.bat"
echo Downloading "wp-cli.phar"...
echo.
:: Download wp-cli.phar to the current directory
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
:: Inform the user
cls
echo %wp_cli_cache%
echo WP CLI installed successfully.
echo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment