language: node_js
node_js:
  - "0.6"
  - "0.8"
  - "0.10"
env:
  global:
    - BIN="node" BUILD=false COMPAT=false MAKE=false OPTION="" SAUCE_LABS=false SAUCE_USERNAME="lodash"
    - secure: "tg1JFsIFnxzLaTboFPOnm+aJCuMm5+JdhLlESlqg9x3fwro++7KCnwHKLNovhchaPe4otC43ZMB/nfWhDnDm11dKbm/V6HlTkED+dadTsaLxVDg6J+7yK41QhokBPJOxLV78iDaNaAQVYEirAgZ0yn8kFubxmNKV+bpCGQNc9yU="
  matrix:
    - BUILD="compat"
    - BUILD="modern"
    - BUILD="legacy"
    - BUILD="mobile"
    - BIN="phantomjs" BUILD="compat"
    - BIN="phantomjs" BUILD="legacy"
    - BIN="phantomjs" BUILD="mobile"
matrix:
  include:
    - node_js: "0.10"
      env: BIN="istanbul"
    - node_js: "0.10"
      env: BIN="narwhal" BUILD="compat"
    - node_js: "0.10"
      env: BIN="narwhal" BUILD="legacy"
    - node_js: "0.10"
      env: BIN="rhino"   BUILD="compat"
    - node_js: "0.10"
      env: BIN="rhino"   BUILD="legacy"
    - node_js: "0.10"
      env: BIN="rhino"   BUILD="compat" OPTION="-require"
    - node_js: "0.10"
      env: BIN="rhino"   BUILD="legacy" OPTION="-require"
    - node_js: "0.10"
      env: BIN="ringo"   BUILD="compat"
    - node_js: "0.10"
      env: BIN="ringo"   BUILD="legacy"
    - node_js: "0.8"
      env: SAUCE_LABS=true BUILD="compat"
    - node_js: "0.8"
      env: SAUCE_LABS=true BUILD="modern"
    - node_js: "0.8"
      env: SAUCE_LABS=true BUILD="legacy"
    - node_js: "0.8"
      env: SAUCE_LABS=true BUILD="mobile"
    - node_js: "0.8"
      env: SAUCE_LABS=true BUILD="underscore"
git:
  depth: 10
branches:
  only:
    - master
before_install:
  - "([ $BUILD == 'legacy' ] || [ $BUILD == 'mobile' ] || [ $BUILD == 'modern' ]) && MAKE=true || true"
  - "([ $BUILD == 'compat' ] || [ $BUILD == 'legacy' ]) && COMPAT=true || true"
  - "[ $SAUCE_LABS != false ] && npm i ecstatic@\"~0.4.0\" request@\"~2.27.0\" sauce-tunnel@\"~1.1.0\" || true"
  - "[ $BIN == 'istanbul' ] && npm i -g coveralls@\"~2.5.0\" istanbul@\"~0.1.0\" || true"
  - "[ $BIN == 'narwhal' ] && wget https://github.com/280north/narwhal/archive/v0.3.2.zip && sudo unzip v0.3.2 -d /opt/ && rm v0.3.2.zip || true"
  - "[ $BIN == 'narwhal' ] && sudo ln -s /opt/narwhal-0.3.2/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal || true"
  - "[ $BIN == 'rhino' ] && sudo mkdir /opt/rhino-1.7R5 && sudo wget -O /opt/rhino-1.7R5/js.jar https://oss.sonatype.org/content/repositories/snapshots/org/mozilla/rhino/1.7R5-SNAPSHOT/rhino-1.7R5-20120629.144839-4.jar || true"
  - "[ $BIN == 'rhino' ] && echo -e '#!/bin/sh\\njava -jar /opt/rhino-1.7R5/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino || true"
  - "[ $BIN == 'ringo' ] && wget http://ringojs.org/downloads/ringojs-0.9.zip && sudo unzip ringojs-0.9 -d /opt && rm ringojs-0.9.zip || true"
  - "[ $BIN == 'ringo' ] && sudo ln -s /opt/ringojs-0.9/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo || true"
  - "[ $MAKE != false ] && git clone --depth=10 --branch=master git://github.com/lodash/lodash-cli.git ./node_modules/lodash-cli || true"
  - "[ $MAKE != false ] && mkdir ./node_modules/lodash-cli/node_modules && cd ./node_modules/lodash-cli/node_modules/ && ln -s ../../../ ./lodash && cd ../ && npm i . && cd ../../ || true"
  - "[ $MAKE != false ] && node ./node_modules/lodash-cli/bin/lodash $BUILD -o ./dist/lodash.$BUILD.js || true"
script:
  - "[ $BIN == 'istanbul' ] && $BIN cover -x \"**/vendor/**\" --report lcovonly ./test/test.js -- ./dist/lodash.js && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage || true"
  - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || cd ./test"
  - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.js"
  - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.min.js"
  - "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=lodash-$BUILD\" tags=\"$BUILD,production\""
  - "([ $SAUCE_LABS == false ] || [ $COMPAT == false ])       && true || node ./test/saucelabs.js runner=\"test/index.html?build=lodash-$BUILD\" tags=\"$BUILD,production,ie-compat\" compatMode=7"
  - "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development\""
  - "([ $SAUCE_LABS == false ] || [ $COMPAT == false ])       && true || node ./test/saucelabs.js runner=\"test/index.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development,ie-compat\" compatMode=7"
  - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"backbone tests\"   runner=\"test/backbone.html?build=lodash-$BUILD\" tags=\"$BUILD,production,backbone\""
  - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"backbone tests\"   runner=\"test/backbone.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development,backbone\""
  - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=lodash-$BUILD\" tags=\"$BUILD,production,underscore\""
  - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development,underscore\""
