Awesome FOSS Logo
Discover awesome open source software
Launched 🚀🧑‍🚀

Absurdly useful tooling: entr + make (+ find)


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:

  • Node & NPM must be installed
  • You must become acclimated to configuration style of each (they’re all different)
  • You must be come acclimate to their dominant paradigmns
    • Grunt is file transformation based
    • Gulp is stream transformation based
    • Broccoli is Tree based on the surface, but I think uses or is similar to gulp underneath the covers
    The actual lower level details/implementations of systems that perform the watch-and-execute-commands vary from system to system. To avoid polling files for changes, some systems use 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:

  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!