I'm building a web site and have multiple js files all in one directory. When I save any one of the js files I want a script to run that will compile and compress all files using the google closure compiler jar.
Example from Google Closure Compiler README:
java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js
Is there a shell script or app that does this? I'm looking for something similar to how http://incident57.com/less/ works for CSS.
In linux you can use the inotifywait command to listen for changes in a specific folder. This script can you give an idea:
#!/bin/bash
directory=$1
inotifywait -q -m --format '%f' -e modify -e move -e create -e delete ${directory} | while read line
do
echo "doing something with: $line";
# for example:
# java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js
done
You can invoke this script specifying the "monitor" directory, in this way
./inotify.sh ~/Desktop/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With