This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
build-linux
54 lines (45 loc) · 2.26 KB
/
build-linux
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
#!/bin/sh
# Create folders
mkdir -p output
mkdir -p output/lib
#
OutDebugFile='output/intravenous-latest.debug.js'
OutMinFile='output/intravenous-latest.js'
InNpmSpec='npm/package.json'
OutNpmSpec='output/package.json'
InNpmIgnore='npm/.npmignore'
OutNpmIgnore='output/.npmignore'
OutNpmFile='output/lib/intravenous.js'
# Combine the source files
SourceFiles=`grep js < fragments/source-references.js | # Find JS references
sed "s/[ \',]//g" | # Strip off JSON fluff (whitespace, commas, quotes)
sed -e 's/.*/..\/&/' | # Fix the paths by prefixing with ../
tr '\n' ' '` # Combine into single line
cat fragments/amd-pre.js > $OutDebugFile.temp
cat $SourceFiles >> $OutDebugFile.temp
cat fragments/amd-post.js >> $OutDebugFile.temp
# Now call Google Closure Compiler to produce a minified version
curl -d output_info=compiled_code -d output_format=text -d compilation_level=ADVANCED_OPTIMIZATIONS --data-urlencode "js_code=/**@const*/var DEBUG=false;" --data-urlencode js_code@$OutDebugFile.temp "http://closure-compiler.appspot.com/compile" > $OutMinFile.temp
# Finalise each file by prefixing with version header and surrounding in function closure
cp fragments/version-header.js $OutDebugFile
echo "(function(window,undefined){" >> $OutDebugFile
echo "var DEBUG=true;" >> $OutDebugFile
cat $OutDebugFile.temp >> $OutDebugFile
echo "})(typeof window !== \"undefined\" ? window : global);" >> $OutDebugFile
rm $OutDebugFile.temp
cp fragments/version-header.js $OutMinFile
echo "(function(window,undefined){" >> $OutMinFile
cat $OutMinFile.temp >> $OutMinFile
echo "})(typeof window !== \"undefined\" ? window : global);" >> $OutMinFile
rm $OutMinFile.temp
# Inject the version number string
Version=`cat fragments/version.txt`
sed -i~ -e "s/##VERSION##/$Version/g" $OutDebugFile $OutMinFile
# Create NPM
cp $InNpmSpec $OutNpmSpec
cp $InNpmIgnore $OutNpmIgnore
sed -i~ -e "s/##VERSION##/$Version/g" $OutNpmSpec
cp $OutDebugFile $OutNpmFile
# Delete the odd files left behind on Mac
rm -f output/*.js~
rm -f output/*.json~