Skip to content

Commit c6b0246

Browse files
fix script
1 parent b82bfe4 commit c6b0246

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

setup.sh

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ TEMP_DIR=$(mktemp -d)
99
# Detect OS
1010
OS="$(uname -s)"
1111
case "$OS" in
12-
Linux*) FILE="json-to-sql-linux.zip" ;;
13-
Darwin*) FILE="json-to-sql-macos.zip" ;;
12+
Linux*)
13+
FILE="json-to-sql-linux.zip"
14+
FILENAME="json-to-sql-linux"
15+
;;
16+
Darwin*)
17+
FILE="json-to-sql-macos.zip"
18+
FILENAME="json-to-sql-macos"
19+
;;
20+
1421
*) echo "Unsupported OS: $OS"; exit 1 ;;
1522
esac
1623

24+
1725
# Get the correct binary URL
1826
BINARY_URL=$(echo "$LATEST_RELEASE" | grep "browser_download_url" | grep "$FILE" | cut -d '"' -f 4)
1927

@@ -35,19 +43,9 @@ fi
3543
# Extract the binary
3644
unzip -q "$TEMP_DIR/$FILE" -d "$TEMP_DIR"
3745

38-
# Check if the extracted directory exists
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-
44-
if [[ ! -d "$EXTRACTED_DIR" ]]; then
45-
echo "Error: Extracted directory not found."
46-
exit 1
47-
fi
4846

4947
# Check if the binary exists in the extracted directory
50-
BINARY_PATH=$(find "$TEMP_DIR" -type f -name "json-to-sql" | head -n 1)
48+
BINARY_PATH=$(find "$TEMP_DIR" -type f -name "$FILENAME" | head -n 1)
5149
if [[ -z "$BINARY_PATH" ]]; then
5250
echo "Error: Extracted binary not found."
5351
exit 1
@@ -56,7 +54,7 @@ fi
5654
# Install the binary
5755
echo "Installing to $INSTALL_DIR..."
5856
sudo mv "$BINARY_PATH" "$INSTALL_DIR/json-to-sql"
59-
sudo chmod +x "$INSTALL_DIR/json-to-sql"
57+
sudo chmod +x "$INSTALL_DIR"
6058

6159
# Cleanup
6260
rm -rf "$TEMP_DIR"

0 commit comments

Comments
 (0)