forked from google/blockly-android
-
Notifications
You must be signed in to change notification settings - Fork 1
/
updatejs
executable file
·64 lines (54 loc) · 1.47 KB
/
updatejs
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
61
62
63
64
#!/bin/bash
# Copies the compressed Blockly JavaScript files from a local copy of
# Blockly for Web.
#
# Usage:
# updatejs [SourceDir]
# where SourceDir is the directory path to a local copy of web Blockly.
# By default, this is assumed to be ../web.
web_blockly_path="../web"
core_assets_path="blocklylib-core/src/main/assets"
# space delimited source/destination filename pairs
FILES=(\
"blockly_compressed.js ${core_assets_path}/blockly_compressed.js"\
"blocks_compressed.js ${core_assets_path}/blocks_compressed.js"\
"javascript_compressed.js ${core_assets_path}/javascript_compressed.js"\
"msg/js/en.js ${core_assets_path}/msg/js/en.js"
)
ERROR_RUN_AT_ROOT=1
ERROR_DIR_NOT_FOUND=2
ERROR_MISSING_FILES=3
if [ ! -d "./blocklylib-core" ]; then
>&2 echo "Please run from root of blockly-android git repo"
exit $ERROR_RUN_AT_ROOT
fi
if [[ ! -z $1 ]]; then
# Strip the trailing slash, and make sure it is a directory
if [ -d ${1%/} ]; then
web_blockly_path=${1%/}
else
>&2 echo "Unknown directory: ${1}"
exit $ERROR_DIR_NOT_FOUND
fi
fi
found_files=true
for i in "${FILES[@]}"; do
files=(${web_blockly_path}/$i)
src=${files[0]}
dest=${files[1]}
if [[ ! -r $src ]]; then
found_files=false
echo "ERROR: File missing: $src"
fi
done
if [ ! $found_files = true ]; then
exit $ERROR_MISSING_FILES
fi
for i in "${FILES[@]}"; do
files=(${web_blockly_path}/$i)
src=${files[0]}
dest=${files[1]}
echo "cp $src $dest"
cp $src $dest
done
exit 0