I just launched a new course on ES6! Use the code WESBOS for $10 off.

Strengthen your core JavaScript skills and master all that ES6 has to offer. Start Now →

Growl notifications for the Node.js CoffeeScript complier

Two things I’ve been working with lately have been Node.js and CoffeeScript. If you haven’t heard of either, Node.js is server side javascript and CoffeeScript is a ruby/python like langage that compiles down to regular javascript.

The way I develop my CoffeeScript is by using the Node.js compiler to watch my `scripts.coffee` for any changes and compile it into normal JavaScript every time I save my file. The process is instant, but I need to watch my terminal window to see if there were any compiling errors. As you can imagine, this can get fairly annoying especially if you aren’t on dual monitors.

So, my solution was to write a Node.js module that would send a growl notification to the user when the compile was finished. I made use of the growlnotify command line plugin for OSX.

To use, you need to first install growlnotify.

Then use NPM to install the package `npm install coffeescript-growl`

Finally, require (with -r or –require) the module when you compile your script. I like to use something like this:

`coffee -r coffeescript-growl –watch –compile ~/sites/my_project/scripts.coffee`

Thats it! If you have any suggestions or fixes, please fork me on github and follow me on twitter.

This entry was posted in JavaScript, NodeJS. Bookmark the permalink.

5 Responses to Growl notifications for the Node.js CoffeeScript complier

  1. Morgan says:

    Wow, great work. Was thinking I needed something like this morning while I was doing some coffeescript work and due to limited screenspace I didn’t see the errors coming out of the coffee compiler since the terminal screen was minimized.

    • zoz says:

      Thanks for the great tool and article!
      fyi, I had to fool with the coffee command a bit, but now its working great. Here is what I ended up with for my system:

      coffee -r ‘coffeescript-growl’ –watch –compile test.coffee

      (i.e. quote the require and use double dash if using full word options)

  2. Pingback: links for 2011-07-20 « Bloggitation

  3. samuelgilman says:

    Why do you like coffee script?

  4. Tad Thorley says:

    This is awesome!

    My Cakefile now:

    sys = require ‘sys’
    {spawn} = require ‘child_process’

    task “watch”, “watch and compile coffeescript files when modified”, ->
    source = ‘public/coffeescripts’
    destination = ‘public/javascripts’
    sys.puts “Starting coffeescript watcher…”
    sys.puts “#{source} -> #{destination}”
    watcher = spawn ‘coffee’, [‘-cwl’, ‘-r’, ‘coffeescript-growl’, ‘-o’, destination, source]

    [watcher].forEach (child) ->
    child.stdout.on ‘data’, (data) ->
    sys.print data
    child.stderr.on ‘data’, (data) ->
    sys.print data

Leave a Reply

Your email address will not be published. Required fields are marked *