-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathrender_mocks_cli
executable file
·47 lines (39 loc) · 1.32 KB
/
render_mocks_cli
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
#!/usr/bin/env bash
set -e
programname=$0
PLOTLYJS_URL="https://cdn.plot.ly/plotly-1.54.0.min.js"
function usage {
echo "usage: $programname output_folder [docker:image]"
echo " it renders all the JSON files found in ./test/image/mocks into the output_folder."
echo " if docker:image is provided, rendering is done in the given Docker image."
exit 1
}
# if less than two arguments supplied, display usage
if [ $# -le 0 ]
then
usage
fi
for format in png pdf svg eps emf json
do
# To obtain reproducible results, we need to use software rendering
export LIBGL_ALWAYS_SOFTWARE=true
export GALLIUM_DRIVER=softpipe
# Supply defaults assets to Orca
ORCA_OPTS=(--topojson /plotly-geo-assets.js --mathjax /mathjax/MathJax.js)
# pin Plotly.js' version
ORCA_OPTS+=(--plotlyJS "$PLOTLYJS_URL")
# Set Orca options
ORCA_OPTS+=(--verbose --format "$format" --output-dir "$1")
if [ -z "$2" ]; #
then
echo "Executing locally"
echo "Generating figures in \"$format\" format"
orca graph "${ORCA_OPTS[@]}" test/image/mocks/*.json
else
echo "Executing into Docker image \"$2\""
echo "Generating figures in \"$format\" format"
docker run -v "$(pwd)":"$(pwd)" -w "$(pwd)" -it \
-e LIBGL_ALWAYS_SOFTWARE -e GALLIUM_DRIVER \
"$2" graph "${ORCA_OPTS[@]}" test/image/mocks/*.json
fi
done