texcmp.sh 971 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. set -x
  3. imgname=katex/texcmp
  4. tag=1.3
  5. imgid=$(docker images | awk "/${imgname//\//\\/} *${tag//./\\.}/{print \$3}")
  6. cd "$(dirname "$0")" || exit $?
  7. if [[ -z ${imgid} ]]; then
  8. docker build -t "${imgname}:${tag}" . || exit $?
  9. fi
  10. cd ../..
  11. mkdir -p test/screenshotter/{tex,diff}
  12. cleanup() {
  13. [[ "${container}" ]] \
  14. && docker stop "${container}" >/dev/null \
  15. && docker rm "${container}" >/dev/null
  16. container=
  17. }
  18. container=$(docker create -t -u 0:0 \
  19. -w /KaTeX/dockers/texcmp \
  20. "${imgname}:${tag}" \
  21. nodejs texcmp.js "$@")
  22. trap cleanup EXIT
  23. tar c dockers/texcmp/{texcmp.js,package.json} \
  24. test/screenshotter/{ss_data.{js,yaml},images/*-firefox.png,test.tex} \
  25. | docker cp - "${container}:/KaTeX"
  26. docker start -a "${container}"
  27. docker cp "${container}:/KaTeX/test/screenshotter/tex" test/screenshotter \
  28. || exit $?
  29. docker cp "${container}:/KaTeX/test/screenshotter/diff" test/screenshotter \
  30. || exit $?
  31. cleanup