Automate build with inotify-tools

Recently I started to work on a new project Backbone Mobile. This will be very modular approach for html5 widgets for mobile web applications. Since it's modular, I wanted to keep all CSS and JavaScript files separated and create "bundle" with "make" command. 

I found it would be great to build it automatically whenever any CSS or JS files are changed for development purposes and I started to look for options. First closest solution is "incron". This is cron-like service which keep track of file system events and execute command whenever binded event is fired by kernel. But it had one downside - no way to track newly created files or track directories recursively. 

Next - I found inotify-tools package available in Ubuntu repositories and installed it:

sudo apt-get install inotify-tools

This package provide tool "inotifywait" which have recursive option! Here is short BASH script I am using to auto-build CSS&JS dependencies for my project:


#!/bin/bash

# get the current path
CURPATH=`pwd`

inotifywait -mqr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' \
-e close_write ./css ./js | while read date time dir file; do
  ext="${file##*.}"
  if [[ "$ext" = "css" || "$ext" = "js" ]]; then
    FILECHANGE=${dir}${file}
    # convert absolute path to relative
    FILECHANGEREL=`echo "$FILECHANGE" | sed 's_'$CURPATH'/__'`

    echo "At ${time} on ${date}, file $FILECHANGE was changed. Rebuilding."

    # Actual command to execute when CSS or JS file is changed
    make -B
  fi

I think i just had a light

I think i just had a light bulb appear over my head thanks to your blog. lol good job.physician assistant programs in california

You should better buy essays

You should better buy essays and read all tips about what you need to do.

To my mind it should be

To my mind it should be better to know more abiut Drupal services here!college essays

amazing good work i realy

amazing good work i realy like your post

Logo Design