language: node_js
sudo: false
node_js:
  - '4.2.2'

addons:
  apt:
    sources:
    - ubuntu-toolchain-r-test
    packages:
    - gcc-4.8
    - g++-4.8
    sauce_connect:
      # Update SAUCE_USERNAME / SAUCE_ACCESS_KEY in travis if necessary
      # https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
      sauce_connect: true

cache:
  directories:
    - node_modules

env:
  global:
  - CXX=g++-4.8
  - alias tsc=./node_modules/.bin/tsc
  - alias grunt=./node_modules/grunt-cli/bin/grunt

before_install:
  - npm install -g npm@3 && npm install grunt@0.4.1 grunt-cli grunt-contrib-connect grunt-run
install:
  - npm install && npm run lint

script:
  - npm run build_spec && npm run test_mocha && node ./node_modules/markdown-doctest/bin/cmd.js
  - npm run check_circular_dependencies

after_success:
  - npm run cover
  - cat ./coverage/coverage-remapped.lcov | ./node_modules/coveralls/bin/coveralls.js
  - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ -n "${SAUCE_ACCESS_KEY}" ] && npm run build_spec_browser && grunt --gruntfile spec/support/mocha.sauce.gruntfile.js || false'