Skip to content

Commit

Permalink
Update test-init.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Vignesh Skanda  <[email protected]>
  • Loading branch information
vignesh1507 authored Sep 23, 2024
1 parent 8fbb1f0 commit 2caf9fd
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions scripts/test-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,29 @@ url="https://kanaries-app.s3.ap-northeast-1.amazonaws.com/public-datasets/bike_s
dir="./tests"

# Create the directory if it doesn't exist
mkdir -p "$dir"
mkdir -p "$dir" || {
echo "Error: could not create directory '$dir'" >&2
exit 1
}

# Download the file using curl
if command -v curl >/dev/null; then
curl "$url" -o "$dir/bike_sharing_dc.csv"
curl -f "$url" -o "$dir/bike_sharing_dc.csv" || {
echo "Error: could not download file from '$url'" >&2
exit 1
}
elif command -v wget >/dev/null; then
wget "$url" -O "$dir/bike_sharing_dc.csv"
wget -q --show-progress "$url" -O "$dir/bike_sharing_dc.csv" || {
echo "Error: could not download file from '$url'" >&2
exit 1
}
else
echo "Error: could not find curl or wget to download the file" >&2
exit 1
fi
fi

# Check if the file was downloaded successfully
if [ ! -f "$dir/bike_sharing_dc.csv" ]; then
echo "Error: file '$dir/bike_sharing_dc.csv' was not downloaded successfully" >&2
exit 1
fi

0 comments on commit 2caf9fd

Please sign in to comment.