-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.sh
39 lines (28 loc) · 845 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
#!/bin/bash
if [ "$1" = "test" ] ; then
BUILD_DIR="tests/build/"
MAIN_FILE="tests/TestMain.ts"
TARGET_DIR="tests/"
SOURCES=`find $TARGET_DIR -maxdepth 1 -name "*.ts"`
else
BUILD_DIR="build/"
MAIN_FILE="main.ts"
TARGET_DIR="."
SOURCES=`find $TARGET_DIR -maxdepth 1 -name "*.ts"`
fi
echo "I'm compiling the following files:${SOURCES[@]}"
tsc --target "ES5" --module "amd" $MAIN_FILE
if [ $? -ne 0 ] ; then
echo "Some files failed to compile. Terminating the process..."
exit 1
fi
echo "All files compiled"
echo "Now moving generated files to the build directory..."
TARGETS=(`find $TARGET_DIR -maxdepth 1 -name "*.js"`)
echo "First clean the build directory..."
rm "$BUILD_DIR*"
echo "And then move..."
for FILE in ${TARGETS[@]} ; do
mv -u $FILE $BUILD_DIR
done
echo "Successfully compiled!"