@@ -22,27 +22,33 @@ if [[ -z "$BINARY_URL" ]]; then
2222  exit  1
2323fi 
2424
25- #  Download and extract  the binary
25+ #  Download the binary zip file 
2626echo  " Downloading json-to-sql ($OS )..." 
2727curl -L " $BINARY_URL "   -o " $TEMP_DIR /$FILE " 
2828
29- echo  " Extracting..." 
30- unzip -q " $TEMP_DIR /$FILE "   -d " $TEMP_DIR " 
29+ #  Check if the zip file is empty
30+ if  [[ $( unzip -l " $TEMP_DIR /$FILE "   |  wc -l)   -le  3 ]];  then 
31+   echo  " Error: The zip file is empty or does not contain the expected binary." 
32+   exit  1
33+ fi 
3134
32- #  List contents of the temporary directory for debugging
33- echo  " Contents of $TEMP_DIR :" 
34- ls -l " $TEMP_DIR " 
35+ #  Extract the binary
36+ unzip -q " $TEMP_DIR /$FILE "   -d " $TEMP_DIR " 
3537
3638#  Check if the extracted directory exists
37- EXTRACTED_DIR=" $TEMP_DIR /json-to-sql-${OS} " 
39+ EXTRACTED_DIR=" $TEMP_DIR /json-to-sql-macOS" 
40+ if  [[ " $OS "   ==  " Linux"   ]];  then 
41+   EXTRACTED_DIR=" $TEMP_DIR /json-to-sql-Linux" 
42+ fi 
43+ 
3844if  [[ !  -d  " $EXTRACTED_DIR "   ]];  then 
3945  echo  " Error: Extracted directory not found." 
4046  exit  1
4147fi 
4248
4349#  Check if the binary exists in the extracted directory
44- BINARY_PATH=" $EXTRACTED_DIR / json-to-sql" 
45- if  [[ !   -f  " $BINARY_PATH "   ]];  then 
50+ BINARY_PATH=$( find  " $TEMP_DIR "  -type f -name  " json-to-sql"   |  head -n 1 ) 
51+ if  [[ -z  " $BINARY_PATH "   ]];  then 
4652  echo  " Error: Extracted binary not found." 
4753  exit  1
4854fi 
0 commit comments