Created
January 8, 2020 21:18
-
-
Save t-mw/8614b805e464f3dd73d888988e0025fb to your computer and use it in GitHub Desktop.
See https://github.com/porglezomp-misc/live-reloading-rs/issues/1. Requires `inotify-tools`.
This file contains 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 | |
# see https://github.com/porglezomp-misc/live-reloading-rs/issues/1 | |
set -e | |
name="libreloadable" | |
extension="so" | |
dir="./target/debug" | |
path="${dir}/${name}.${extension}" | |
cleanup() { | |
rm -f "${dir}/${name}_"*; | |
} | |
trap cleanup EXIT | |
timestamp() { | |
date +"%s"; | |
} | |
run() { | |
name2="${name}_$(timestamp)"; | |
for f in "$dir/$name".*; do cp -r "$f" "${f/$name/$name2}"; done | |
} | |
export name | |
export extension | |
export dir | |
export path | |
export -f timestamp | |
export -f run | |
inotifywait --include "$name\.$extension" -m -e CREATE "$dir" | xargs -n1 sh -c '$(run);' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment