-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
75 lines (59 loc) · 1.2 KB
/
build.sh
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env sh
# Font helpers.
VERSION="6.1.3"
URL="https://github.com/be5invis/Iosevka/archive/refs/tags/v$VERSION.tar.gz"
DIR="src"
# Color helpers.
RED="\033[0;31m"
GRN="\033[0;32m"
CLR="\033[0m"
log() {
printf "$GRN%s$CLR %s\n" "$(date +%F\ %H:%M:%S)" "$@"
}
lor() {
printf "$RED%s$CLR %s\n" "$(date +%F\ %H:%M:%S)" "$@"
}
cmd() {
if ! command -v "$1" >/dev/null; then
lor "Missing '$1' command. Build stopped."
exit 1
fi
}
err() {
out="$?"
if [ ! "$out" = 0 ]; then
lor "Ran into an error. Build stopped."
exit 1
fi
}
download() {
if [ -d "$DIR" ]; then
log "Source code is already available."
else
log "Downloading and extracting source code."
curl -L $URL | tar xz
mv Iosevka-* $DIR
fi
}
build() {
cp viosevka.toml $DIR/private-build-plans.toml
cd $DIR
cmd npm
log "Installing NPM dependencies."
npm install
log "Building default font."
npm run build -- ttf::viosevka
}
link() {
cd ..
if [ ! -L "font" ]; then
ln -s "$DIR/dist/viosevka" font
fi
log "Font built successfully."
}
main() {
download || err
build || err
link || err
}
main