-
Notifications
You must be signed in to change notification settings - Fork 592
/
build-examples.sh
executable file
·48 lines (34 loc) · 1.35 KB
/
build-examples.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
#!/usr/bin/env bash
# script for npm run x-compile
set -eo pipefail
dir=${dir-"examples/compiled"}
echo "Compiling examples to $dir"
# Check if param is provided
if [[ -z "$1" ]];
then
forcesvg=false
else
forcesvg=true
fi
# record vega version and force rebuild SVG if version does not match
rm -f $dir/vega-version
echo "vega: `./scripts/version.sh vega`" > $dir/vega_version
if ! git diff --no-patch --exit-code $dir/vega_version
then
forcesvg=true
fi
export forcesvg
nopatch='--no-patch'
export nopatch
skipnormalize=false
export skipnormalize
# Clean up outdated normalized vega-lite files and vega files
rm -f examples/specs/normalized/*_normalized.vl.json
rm -f $dir/*.vg.json
# Re-compile all examples
echo "Using parallel to generate vega specs from examples in parallel."
ls examples/specs/*.vl.json | parallel --env skipnormalize --env forcesvg --env nopatch --no-notice --plus --halt 1 "scripts/build-example.sh {/..}"
scripts/build-normalized-examples
# Clean up outdated svg and png files (This has to be done by checking files as we do not always regenerate svgs)
ls examples/compiled/*.svg | parallel --no-notice --plus --halt 1 "[ -f examples/specs/{/..}.vl.json ] || rm -f examples/compiled/{/..}.svg"
ls examples/compiled/*.png | parallel --no-notice --plus --halt 1 "[ -f examples/specs/{/..}.vl.json ] || rm -f examples/compiled/{/..}.png"