-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
60 lines (50 loc) · 1.4 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
#!/bin/bash
#
# @desc Generate single HTML of Kapur Markdown Editor
# @author Rio Astamal <[email protected]>
# @link https://github.com/rioastamal/kapur
#
[ ! -f src/lib/codemirror.js ] && {
echo "Error: Make sure you run this script on root directory of html-editor." >&2
exit 1
}
KAPUR_VERSION=1.2
JS_CONTENTS=
CSS_CONTENT=
BUILD_FILE=build/kapur-${KAPUR_VERSION}.html
cp src/kapur.html $BUILD_FILE
CODEMIRROR_LINE_BEGIN=$( sed -n '/!-- BEGIN CODEMIRROR -->/=' $BUILD_FILE )
CODEMIRROR_LINE_END=$( sed -n '/!-- END CODEMIRROR -->/=' $BUILD_FILE )
CONTENTS_BEFORE_CODEMIRROR=$( head -n $CODEMIRROR_LINE_BEGIN $BUILD_FILE )
CONTENTS_AFTER_CODEMIRROR=$( tail +$CODEMIRROR_LINE_END $BUILD_FILE )
for js in src/lib/*.js
do
JS_CONTENTS="${JS_CONTENTS}
// --- File: $js
$( cat $js )
"
done
for js in src/mode/*.js
do
JS_CONTENTS="${JS_CONTENTS}
// --- File: $js
$( cat $js )
"
done
for css in src/css/*.css
do
CSS_CONTENTS="${CSS_CONTENTS}
/* --- File: $css ---*/
$( cat $css )
"
done
echo "$CONTENTS_BEFORE_CODEMIRROR" > $BUILD_FILE
echo "<script>$JS_CONTENTS</script>" >> $BUILD_FILE
echo "<style>$CSS_CONTENTS</style>" >> $BUILD_FILE
echo "$CONTENTS_AFTER_CODEMIRROR" >> $BUILD_FILE
# If we have zip command then compress the build file
hash zip && {
zip build/kapur-${KAPUR_VERSION}.zip $BUILD_FILE;
}
ln -fs kapur-${KAPUR_VERSION}.html build/kapur.html
echo "Build file $BUILD_FILE complete."