Skip to content

Instantly share code, notes, and snippets.

@letsgetrandy
Last active December 17, 2015 23:19
Show Gist options
  • Save letsgetrandy/5688410 to your computer and use it in GitHub Desktop.
Save letsgetrandy/5688410 to your computer and use it in GitHub Desktop.
Setup script for UI testing tools (Mac, Linux)
#!/bin/bash
#
# Install UI tools
# - node
# - jshint
# - csslint
# - phantomjs
# - casperjs
# - specter
MIN_NODE_VERSION="v0.10.12"
MIN_PHANTOM_VERSION="1.9.1"
MIN_CASPER_VERSION="1.0.2"
MIN_SPECTER_VERSION="0.2"
if [ ! -d /usr/local/opt ]; then
mkdir /usr/local/opt
fi
unamestr=`uname`
if [[ " $@" != *" --skip-node"* ]]; then
# Install Node
if [[ "$unamestr" == "Darwin" ]]; then
# Use homebrew on Mac
brew install node
else
# Build from source on Linux
NODE_BASE="node-v${MIN_NODE_VERSION}"
if [ "$(/usr/local/bin/node --version 2>/dev/null)" != "${MIN_NODE_VERSION}" ]; then
pushd /usr/local
wget http://nodejs.org/dist/v0.10.12/node-v0.10.12.tar.gz
tar -zxvf node-v0.10.12.tar.gz && rm ${NODE_BASE}.tar.gz*
cd node-v0.10.12
./configure
make
make install
popd
fi
fi
# Install JSHint
npm install -g jshint
# Install CSSLint
npm install -g csslint
fi
# Install PhantomJS
if [[ " $@" != *" --skip-phantom"* ]]; then
if [[ "$unamestr" == "Darwin" ]]; then
# Use homebrew on Mac
brew install phantomjs
else
# Grab the x86/64 binaries on Linux
PHANTOM_BASE="phantomjs-${MIN_PHANTOM_VERSION}-linux-x86_64"
if [ "$(/usr/local/bin/phantomjs --version 2>/dev/null)" != "${MIN_PHANTOM_VERSION}" ]; then
DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install libfontconfig1-dev
pushd /usr/local/
rm -rf phantomjs-*
wget --quiet http://phantomjs.googlecode.com/files/${PHANTOM_BASE}.tar.bz2
tar -jxvf ${PHANTOM_BASE}.tar.bz2 && rm ${PHANTOM_BASE}.tar.bz2*
ln -nfs /usr/local/${PHANTOM_BASE}/bin/phantomjs /usr/local/bin/phantomjs
popd
fi
fi
fi
# Confirm installations
echo
echo "node version: `node --version`"
echo "jshint version: `jshint --version`"
echo "csslint version: `csslint --version`"
echo "phantomjs version: `phantomjs --version`"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment