#!/bin/bash
PHANTOM_VERSION=${1-1.9.2}
PHANTOM_SOURCE=https://phantomjs.googlecode.com/files/phantomjs-$PHANTOM_VERSION-linux-x86_64.tar.bz2

# don't run the install process if we are in use mode
if [ ! $BASHINATE_USE ]; then
  # if we don't have the latest node version, then install
  log "Checking phantomjs version $PHANTOM_VERSION installed";
  if [ ! -e $BASHINATE_INSTALL/phantom/$PHANTOM_VERSION ]; then
    log "Installing phantom version $PHANTOM_VERSION"
    fetchSource $PHANTOM_SOURCE

    mkdir -p $BASHINATE_INSTALL/phantomjs
    mv $BASHINATE_SOURCE/phantomjs-$PHANTOM_VERSION-linux-x86_64/ \
      $BASHINATE_INSTALL/phantomjs/$PHANTOM_VERSION
  fi
fi

linkBinaries phantomjs/$PHANTOM_VERSION/bin phantomjs