-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·40 lines (39 loc) · 1.06 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
#!/bin/bash
# write by @waxzce
echo "building events4js"
echo "if you provide yuicompressor path, minified files will generated in the same time"
# vars
SRC_DIR="src"
BUILD_DIR="build"
# empty the future dir
rm -rf $BUILD_DIR/*
# now building the sources
for i in `ls $SRC_DIR`; do
echo "build $i"
TARGET_FILE="$BUILD_DIR/$i.js"
cat legal/intro.js > $TARGET_FILE
echo "if(modules === undefined){modules = {};}" >> $TARGET_FILE
echo " " >> $TARGET_FILE
echo "modules['$i'] = function(require, exports) {" >> $TARGET_FILE
echo " " >> $TARGET_FILE
for ii in `cat $SRC_DIR/$i/files.order`; do
cat $SRC_DIR/$i/$ii >> $TARGET_FILE
echo " " >> $TARGET_FILE
done
echo " " >> $TARGET_FILE
echo "};" >> $TARGET_FILE
echo " " >> $TARGET_FILE
done
if [ ! -z $1 ]
then
YUIC_PATH=$1
for i in `ls $BUILD_DIR`; do
match=".js"
replacement=".min.js"
TARGET_FILE=$BUILD_DIR/$i
TARGET_FILE=`echo $TARGET_FILE | sed 's/js$/min.js/'`
cat legal/intro.js > $TARGET_FILE
echo " " >> $TARGET_FILE
java -jar $YUIC_PATH $BUILD_DIR/$i --charset utf-8 >> $TARGET_FILE
done
fi