-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·57 lines (45 loc) · 1.17 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
#!/bin/bash
# Check if at least one command line argument is provided
if [ $# -lt 1 ]; then
echo "Usage: $0 [firefox|chrome|opera]"
exit 1
fi
MANIFEST_PATH=""
OUTPUT_FILE_NAME=""
# Check the value of the first command line argument
if [ "$1" == "firefox" ]; then
echo "Building for Firefox..."
MANIFEST_PATH="platform/firefox/manifest.json"
OUTPUT_FILE_NAME="tvp-firefox.xpi"
elif [ "$1" == "chrome" ]; then
echo "Building for Chrome..."
MANIFEST_PATH="platform/chrome/manifest.json"
OUTPUT_FILE_NAME="tvp-chrome.zip"
elif [ "$1" == "opera" ]; then
echo "Building for Opera..."
MANIFEST_PATH="platform/opera/manifest.json"
OUTPUT_FILE_NAME="tvp-opera.zip"
else
echo "Invalid argument. Supported values are 'firefox', 'chrome' and 'opera'."
exit 1
fi
# Compile typescript
npx tsc
# Compile scss
npx sass public/:dist/
# Copy lib to dist
cp -r lib/ dist/
# Create temp dir
mkdir temp
# Copy files into temp dir
cp -r $MANIFEST_NAME public/ dist/ temp
# Copy manifest to temp
cp $MANIFEST_PATH temp/
# Go into temp dir
cd temp
# Zip contents "extension.xpi"
zip -x "*.map" -x "*.scss" -r $OUTPUT_FILE_NAME *
mv $OUTPUT_FILE_NAME ..
cd ..
# Delete temp dir
rm -r temp