Last active
June 16, 2020 19:52
-
-
Save sergyperov/6b11f94ba4959641a75456c767d8e204 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # simple bash script to watch after all drawio files and automatically build .pdf | |
| # fswatch is required: https://github.com/emcrisostomo/fswatch | |
| # drawio is required: https://github.com/jgraph/drawio | |
| APP_PATH='/Applications/draw.io.app/Contents/MacOS/draw.io' # full path to drawio app | |
| SRC_PATH='/Users/someone/someproject/img/drawio' # full path to directory where .drawio files are stored | |
| function drawioBuild { | |
| echo Compiling $1 | |
| pdf_filename="$(basename "$1" .drawio).pdf" | |
| rm -f $pdf_filename | |
| bash -c "$2 --crop -x -o $pdf_filename $1" | |
| } | |
| export -f drawioBuild | |
| # on init process all existing files | |
| /usr/bin/find $SRC_PATH -name *.drawio -print0 | xargs -0 -n1 -I{} bash -c 'drawioBuild "$@"' _ {} $APP_PATH | |
| echo 'Start wathing' | |
| # then watch | |
| fswatch -0 -e ".*" -i "\\.drawio$" $SRC_PATH | xargs -0 -n1 -I{} bash -c 'drawioBuild "$@"' _ {} $APP_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment