-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-single.sh
53 lines (45 loc) · 1.66 KB
/
build-single.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
# Build a single index.html file containing all of the js files
# Run in Coursework/ inside the bash shell on Windows
# set -x #echo on
npx babel chart1.js --out-file out/chart1-compiled.js
sed -i 's/&/\\\\&/g' out/chart1-compiled.js
npx babel chart2.js --out-file out/chart2-compiled.js
sed -i 's/&/\\\\&/g' out/chart2-compiled.js
sed -i 's/\\d/\\\\d/g' out/chart2-compiled.js
sed -i 's/\\\//\\\\\//g' out/chart2-compiled.js
npx babel chart3.js --out-file out/chart3-compiled.js
sed -i 's/&/\\\\&/g' out/chart3-compiled.js
npx babel loadSources.js --out-file out/loadSources-compiled.js
sed -i 's/&/\\\\&/g' out/loadSources-compiled.js
cp index.html out/index.html
# code=$(cat datasources.js)
# replacement='<script>'$code'</script>'
# awk -i inplace -v REP="$replacement" '{
# sub(/<script src="datasources\.js"><\/script>/, REP);
# print;
# }' out/index.html
code=$(cat out/chart1-compiled.js)
replacement='<script>'$code'</script>'
awk -i inplace -v REP="$replacement" '{
sub(/<script src="chart1\.js"><\/script>/, REP);
print;
}' out/index.html
code=$(cat out/chart2-compiled.js)
replacement='<script>'$code'</script>'
awk -i inplace -v REP="$replacement" '{
sub(/<script src="chart2\.js"><\/script>/, REP);
print;
}' out/index.html
code=$(cat out/chart3-compiled.js)
replacement='<script>'$code'</script>'
awk -i inplace -v REP="$replacement" '{
sub(/<script src="chart3\.js"><\/script>/, REP);
print;
}' out/index.html
code=$(cat out/loadSources-compiled.js)
replacement='<script>'$code'</script>'
awk -i inplace -v REP="$replacement" '{
sub(/<script src="loadSources\.js"><\/script>/, REP);
print;
}' out/index.html
rm out/*-compiled.js