-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmerge.bash
executable file
·45 lines (38 loc) · 1.2 KB
/
merge.bash
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
#!/usr/bin/env bash
set -e
./format.bash
{
mkdir -p release/{standalone,split}
# minified install script
{
sed -n 1p install.bash
shfmt -mn -ln bash install.bash
} >| "release/install"
# standlone script
{
sed -n 1p mangadl.bash
printf "%s\n" "SELF_SOURCE=\"true\""
for file in utils/*scraper.bash; do
: "${file#*utils\/}" && source="${_%-scraper.bash}"
ALL_SOURCES+="\"${source}\" "
done
printf "%s" "ALL_SOURCES=(${ALL_SOURCES})" && printf "\n"
{
sed 1d utils/common-utils.bash && sed 1d utils/scraper-utils.bash
for file in utils/*scraper.bash; do
! grep -q "# PLACEHOLDER" "${file}" && sed 1d "${file}"
done
sed 1d mangadl.bash
# minify the standalone script using shfmt
} | shfmt -ln bash -mn
} >| "release/standalone/mangadl"
# split minified utils and main script
for i in mangadl.bash utils/*.bash; do
{
sed -n 1p "${i}"
shfmt -mn "${i}"
} >| "release/split/${i##*\/}"
done
chmod -R +x "release/"*
} &&
printf "%s\n" "Merged and minified successfully."