mor

Cross platform dependency manager

commit df7f27ca47c788a56227badef8e039f3754ac60d
parent 33d274d209cc8d4f952891b3d551935842036324
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 12 Oct 2024 01:42:47 +0530

Fix: Throw proper error when @target's path(/) is wrong
1 file changed, 6 insertions(+), 1 deletion(-)
M
mor.cmd
|
7
++++++-
diff --git a/mor.cmd b/mor.cmd
@@ -62,6 +62,7 @@ setlocal EnableDelayedExpansion
 				set section=%%~l
 				set section=!section:~1!
 				call :parse_target !section! %%~m %%~n
+				if ERRORLEVEL 1 exit /b !ERRORLEVEL!
 			) else (
 				call :prime_download %%~l %%~m %%~n
 				if ERRORLEVEL 1 exit /b !ERRORLEVEL!

@@ -80,6 +81,11 @@ setlocal EnableDelayedExpansion
 	set wsections=![#%section%[/]!
 :MOR_PARSE_TARGET_START
 	for /f "usebackq tokens=1* delims= " %%a in ('!wsections!') do (
+		set [%%a[ 2>NUL >NULL
+		if ERRORLEVEL 1 (
+			echo ^> Cannot find target '%%~a'
+			exit /b 1
+		)
 		for /f "usebackq tokens=1,2,3* delims=[]=" %%e in (`set  [%%a[`) do (
 			if "%%~f"=="%~2-%~3" (
 				call :prime_download %%e %%~f %%~g || exit /b %ERRORLEVEL%

@@ -91,7 +97,6 @@ setlocal EnableDelayedExpansion
 endlocal DisableDelayedExpansion
 goto :eof
 
-
 :prime_download <section> <target> <url>
 setlocal EnableDelayedExpansion
 	set current_target_dir="%root_dir%\%1"