-
Notifications
You must be signed in to change notification settings - Fork 11
/
compile.sh
executable file
·43 lines (32 loc) · 982 Bytes
/
compile.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
#!/usr/bin/env bash
dir="$(realpath "${0%/*}")"
if ! [ -d "${dir}/out" ]; then
mkdir "${dir}/out"
fi &&
rm -rf "${dir}/build" &&
mkdir "${dir}/build" &&
cp "${dir}/src/"*.ts "${dir}/build" &&
cp "${dir}/tsconfig.json" "${dir}/build" &&
(
cd "${dir}/build" &&
for l in ../node_modules/dayjs/locale/*.js; do
echo "import \"dayjs/locale/$(basename "$l" | cut -d. -f1)\";" \
>> ./locales.ts
done &&
sed -i.bak '
s/^\(import .* from "dayjs";.*\)$/\1 import ".\/locales";/;
' ./extension.ts;
esbuild \
--bundle \
--format=cjs \
--charset=utf8 \
--external:vscode \
--outfile=./extension.js \
--target=es2017 \
./extension.ts &&
echo >> ./extension.js &&
echo 'module.exports.activate = activate;' >> ./extension.js &&
echo 'module.exports.deactivate = deactivate;' >> ./extension.js &&
mv ./extension.js "${dir}/out/" &&
rm -rf "${dir}/build"
)