-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch-deps.sh
More file actions
executable file
·51 lines (40 loc) · 1.32 KB
/
fetch-deps.sh
File metadata and controls
executable file
·51 lines (40 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# ---- Whats happening ---- #
# This fetches the dependencies listed in the "libs" variable and saves them in the targetFolder
set -e
# dependencies
# just add TestSuite-lib to the list when you need this suite
libs=(
"ccClass-lib"
)
# Basic setup variables
repo="mc-cc-scripts"
branch="master"
targetFolderName=libs
# fetch files.txt and save each file into the targetFolder
fetch() {
files_txt=$(curl -fsSL "https://raw.githubusercontent.com/$repo/$1/$branch/files.txt")
if [ -z "$files_txt" ]; then
echo "Could not load files.txt for $1"
exit 1
fi
while IFS= read -r FILE; do
url="https://raw.githubusercontent.com/$repo/$1/$branch/$FILE"
mkdir -p "$(dirname "$targetFolderName/$FILE")" # create the folder (and subfolders specified in the files.txt)
rm -f $targetFolderName/$FILE.lua # rm existing file
if ! curl -s -o "$targetFolderName/$FILE" "$url"; then
echo "could not get / write the file $i: '$FILE' to the folder '$targetFolderName'"
exit 1
fi
# echo "saved $1: '$FILE' in '$targetFolderName'"
done < <(echo "$files_txt")
}
if [[ $# -eq 0 ]]; then
# No arguments given, fetch all
for i in "${libs[@]}"; do
fetch "$i"
done
else
# Argument given, fetch arguemt
fetch "$1"
fi