diff --git a/README.md b/README.md index fe39947..698c26d 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ You current working dir is *not* modified, so you can fire any command without l ## Installation 1. Clone or download this repo -1. `chmod u+x ybp` -1. put `ybp` somehwere on your `PATH` -1. Never type `cd ../../../hybris/bin/platform` or `source setantenv.sh` again +1. `chmod u+x ybp` (Linux / macOS only) +1. put `ybp` / `ybp.bat` somehwere on your `PATH` +1. Never type `cd ../../../hybris/bin/platform` or `source setantenv.sh` / `setantenv.bat` again ## Examples diff --git a/ybp.bat b/ybp.bat new file mode 100644 index 0000000..cc1cddf --- /dev/null +++ b/ybp.bat @@ -0,0 +1,32 @@ +@setlocal ENABLEEXTENSIONS + +@set current=%cd% +@for /F %%I in ("%current%") do @set root=%%~dI + +:loop +@if EXIST "%current%\hybris\bin\platform\*" ( + @set platform=%current%\hybris\bin\platform +) +@call :dirname "%current%" current +@IF NOT DEFINED platform IF NOT "%current%"=="%root%" goto :loop + +@IF DEFINED platform ( + @cd "%platform%" + @IF "%1"=="ant" ( + @call setantenv.bat + ) + @%COMSPEC% /c %* +) ELSE ( + echo Could not find hybris/bin/platform folder, will NOT execute '%*' 1>&2 + @EXIT /B 1 +) + +@endlocal +@goto:EOF + +:dirname file varName + @setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION + @SET _dir=%~dp1 + @SET _dir=%_dir:~0,-1% + @endlocal & set %2=%_dir% +@goto:EOF \ No newline at end of file