Created
July 11, 2023 22:47
-
-
Save SamuelDavis/5ebf1c1e4d08042193f61366217980e9 to your computer and use it in GitHub Desktop.
Template Svelte / Solid projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
if [ "$#" -ne 2 ]; then | |
echo "Incorrect number of arguments." | |
exit 1 | |
fi | |
BRANCH=$1 | |
URL="https://github.com/SamuelDavis/templates/archive/refs/heads/$BRANCH.zip" | |
TEMP_FILE="/tmp/templates-$BRANCH.zip" | |
OUTPUT=$(readlink --canonicalize "$2") | |
CONTAINING_DIR="$OUTPUT/templates-$BRANCH" | |
echo "URL: \"$URL\", TEMP_FILE: \"$TEMP_FILE\", OUTPUT: \"$OUTPUT\"" | |
if ! [ -f "$TEMP_FILE" ]; then | |
curl --location "$URL" --output "$TEMP_FILE" | |
else | |
printf "%s already exists\n" "$TEMP_FILE" | |
fi | |
if ! [ -d "$OUTPUT" ]; then | |
unzip "$TEMP_FILE" -d "$OUTPUT" | |
else | |
printf "%s already exists\n" "$OUTPUT" | |
fi | |
mv "$CONTAINING_DIR"/* "$CONTAINING_DIR"/.* "$OUTPUT" | |
rm -rf "$CONTAINING_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment