using spy to watch for changes



~2 min read


264 words

Another entry in my Package Discovery series. Today, I’m looking at spy.

Jaime Pillora wrote a nifty little application called Spy. Described as a file watcher that will restart a process whenever a file within the spied directory changes, it delivers!

I used it to great effect recently to monitor changes to a Go application I was writing and re-running the test suite on any detected changes, but it could be used generally.

If you’re familiar with nodemon, Spy is similar, but can be used cross-platform.


Spy is useful in a ton of contexts…

From anything like watching a go program for changes and re-running tests:

spy go test

To monitoring for changes to javascript files and restarting a node server (whose entry point is server.js):

spy --inc "**/*.js" node server.js

The key here is that you’re telling spy what to do go test or node server.js by watching the current working directory.


Spy is a boon for developers and one more arrow to place in their quiver.

Similar to how Bunyan logs make finding relevant information easier, Spy makes developing easier by shortening the “Edit-Compile-Test loop”, which as Joel Spolsky writes in Daily Builds Are Your Friend is critical for productive engineering:

A crucial observation here is that you have to run through the loop again and again to write a program, and so it follows that the faster the Edit-Compile-Test loop, the more productive you will be, down to a natural limit of instantaneous compiles.

Thank you to Peter Hellberg for the pointer!

Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!