From 05549ce32a924a10c57ab4e7b7c75b62b5fedb09 Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Wed, 30 Jul 2014 17:48:51 +0900 Subject: [PATCH] Add gulp buildpack. --- buildpack/bin/compile | 2 +- buildpack/buildpacks/gulp/bin/common.sh | 26 ++++++++++++++++++++++ buildpack/buildpacks/gulp/bin/compile | 29 +++++++++++++++++++++++++ buildpack/buildpacks/gulp/bin/detect | 8 +++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 buildpack/buildpacks/gulp/bin/common.sh create mode 100755 buildpack/buildpacks/gulp/bin/compile create mode 100755 buildpack/buildpacks/gulp/bin/detect diff --git a/buildpack/bin/compile b/buildpack/bin/compile index 4f69448a..154b55d8 100755 --- a/buildpack/bin/compile +++ b/buildpack/bin/compile @@ -9,7 +9,7 @@ bp_dir=$(cd $(dirname $0); cd ..; pwd) # Load some convenience functions like status() source $bp_dir/bin/common.sh -for pack in node bower; do +for pack in node bower gulp; do if name=$($bp_dir/buildpacks/$pack/bin/detect "$@"); then status "Detected ${name}" $bp_dir/buildpacks/$pack/bin/compile "$@" diff --git a/buildpack/buildpacks/gulp/bin/common.sh b/buildpack/buildpacks/gulp/bin/common.sh new file mode 100644 index 00000000..1dfda70a --- /dev/null +++ b/buildpack/buildpacks/gulp/bin/common.sh @@ -0,0 +1,26 @@ +error() { + echo " ! $*" >&2 + exit 1 +} + +status() { + echo "-----> $*" +} + +protip() { + echo + echo "PRO TIP: $*" | indent + echo "See https://devcenter.heroku.com/articles/nodejs-support" | indent + echo +} + +# sed -l basically makes sed replace and buffer through stdin to stdout +# so you get updates while the command runs and dont wait for the end +# e.g. npm install | indent +indent() { + c='s/^/ /' + case $(uname) in + Darwin) sed -l "$c";; # mac/bsd sed: -l buffers on line boundaries + *) sed -u "$c";; # unix/gnu sed: -u unbuffered (arbitrary) chunks of data + esac +} diff --git a/buildpack/buildpacks/gulp/bin/compile b/buildpack/buildpacks/gulp/bin/compile new file mode 100755 index 00000000..fac33599 --- /dev/null +++ b/buildpack/buildpacks/gulp/bin/compile @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e # fail fast +set -o pipefail # don't ignore exit codes when piping output +# set -x # enable debugging + +# Configure directories +build_dir=$1 +cache_dir=$2 +env_dir=$3 + +bp_dir=$(cd $(dirname $0); cd ..; pwd) + +# Load some convenience functions like status() and indent() +source $bp_dir/bin/common.sh + +# Expose user-installed bower +export PATH=$build_dir/node_modules/.bin:$PATH + +# Get gulp version +gulp_bin=$(which gulp) +status "Using Gulp from ${gulp_bin#$build_dir/}" +gulp -v 2>&1 | indent + +# Run subsequent node/gulp commands from the build path +cd $build_dir + +status "Building" +gulp build 2>&1 | indent diff --git a/buildpack/buildpacks/gulp/bin/detect b/buildpack/buildpacks/gulp/bin/detect new file mode 100755 index 00000000..ef4c700b --- /dev/null +++ b/buildpack/buildpacks/gulp/bin/detect @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# bin/detect + +if [ -f $1/gulpfile.js ]; then + echo "Gulp" && exit 0 +else + echo "no" && exit 1 +fi