Hopefully the information in here is useful to you (if it isn't please get in touch!).
If you want to get the new stuff as soon as it's out though, sign up to the mailing list below.
After the recent rise of task-management related tools like Grunt, Gulp, and Broccoli, I’ve often wonered if there was an easier way to implement some of the most useful features that those tools provide: watch
(of course, watch is not the only thing that these libraries provide, but is often the most unique/useful).
Grunt, Gulp and Broccoli are wonderful tools, and these days basically come hand-in-hand with front-end development, however there are various downsides to installing/using them. To name a few:
kqueue
and some use inotify
, but what I wanted to find was a program that sat above those levels of abstraction. Enter Entr
Entr is wonderfully simple — you feed it a list of files, and a command, and it will watch the noted files for changes, and run which ever command you specify. Written in C, the project is very small, and compilation/installation is a breeze, with absurdly small configure/make time.
I decided to use make
for a FirefoxOS app project that I’m working on (an odd choice for a front-end app, maybe), and wanted to find a way to get this watch functionality without adding too many new dependencies to my app. I happened upon Entr a while ago and it came to mind, and I downloaded, used, and was instantly pleased with it.
I had the most trouble with getting the find
command to return the files that I wanted, without the files I didn’t. My make file now has the following lines:
watch:
find . \
-not -path "./node\_modules/\*" \
-not -path "./jspm\_packages/\*" \
-type f \
-name "\*.js" \
-o -name "\*.css" \
| entr make
The watch
target is basically just a find command to get the files that are important (that I want watched), and piping the output of that find command to entr, and running make (for which the default is to build the project).
I’d theorized using entr for a project, instead of gulp/grunt/broccoli, and having actually done it just recently, it turned out to be pretty easy, and is working great!