Created
May 17, 2012 11:58
-
-
Save searbe/2718411 to your computer and use it in GitHub Desktop.
Automatically install public resources from Symfony2 bundles when a file changes
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 | |
# Useful when you're making lots of changes in bundle/Resources/public and want | |
# to see the changes quickly in your browser. | |
# chmod +x the file then call the command like `./watch_assets.sh` | |
# Make sure you're in the project root directory (the one containing app, src etc) | |
if [ -z `which inotifywait` ] ; then | |
echo "You must install inotify-tools to use watch_assets" | |
exit 1 | |
fi | |
function update_assets { | |
php app/console assets:install web | |
chmod 777 app/cache -R | |
chown `logname`:www-data . -R | |
} | |
echo "Watching ./src/*/Resources/public... " | |
PUB_FILES=`find ./ -path ./src/*/Resources/public` | |
while inotifywait -re modify $PUB_FILES &>/dev/null ; do | |
sleep 1 | |
echo -n "Change spotted! Installing assets... " | |
update_assets &>/dev/null | |
echo "done" | |
if [ ! -z `which notify-send` ] ; then | |
notify-send "Assets updated" "A change was detected & assets were updated" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've added the update_assets function so this gist actually like, works and stuff.
Note that in the update_assets function you should do whatever you want. At least make sure login-name:www-data are the user & group the assets need to belong to with your dev setup.