A Little Script to Make Gulp a Little Easier to Start
I often use gulp to manage web files. If you've never heard of it, it's a JavaScript-based task runner similar to Grunt. I use it for many of the same reasons I've used (and sometimes still use) GUI tools like LiveReload and CodeKit: to process my Sass into CSS, minify and check JavaScript files for errors, auto-refresh browsers when I make a change, that sort of thing. I like gulp for its speed, and the fact that I can extend it pretty easily with node modules.
I usually start gulp by opening a terminal window, changing directories into the project, and running gulp
or gulp <taskname>
. But who has that kind of time?! Now I add a shell script to the project (be it a Drupal or WordPress theme, or whatever), usually called gulpit.sh
, and open that with the Terminal app (or, in my case, iTerm2) instead. This is the entire script:
#!/bin/sh
ABSPATH=$(cd "$(dirname "$0")"; pwd)
cd $ABSPATH
/usr/local/bin/gulp
It changes to the directory where the project lives (using this technique I found on Stack Overflow) and starts gulp, running the default task. I usually open my projects in Path Finder, so the theme is open in its own tab, with gulpit.sh
right there ready to open. There are lots of other ways to accomplish this same task, obviously, but this is one I like.