language: node_js

os:
  - linux
  - osx

node_js:
  - "4"
  - "6"
  - "7"
  - "8"

addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-4.8

env:
  global:
    - secure: A8ieqjLOvpEBcuDKFwEURNLtY9rUT73THx3ym8hnitPBq6ZPrAZ31QjZ55i8vywek+L8YrjcbR3PBZmyiey33TEfN1Z7a3USYB/j1erhYMTsIX3zmqYazhMbeMNAOrh1T5/ei9tlp1nTtYiXNbVbncPBnGYhkhNKHzPgacAm5n29DkeGk4bg333LUXvrxq0ZMFcGCsx3gdPro83HF/gSxQPLJQubAgOFljbHtwa2pTmQprI9IbdcZbh/mEfc3zwqt9zPYT2Pu/gWqMctVkfSaSIyGNVAsmkIMS6iSovwdjJmXhuFxyfhSqNXKR4x+Ha00ELoTD71Oey8VV+CdcVLoVPLMtkw9qai7nrfknWj4Bw+6zwcIkvCWkQ5YuB6SpJUvjf3ZqANU3VaNEbEdzifolMRGkY0i18ivViWe/q78535JLMXFqLtHWy7AusbvGq86TyG9eeP9mTvtD5XSYWUw64vMyCBFJpMfOf1m7XZYKsQ4K8sXiMW9ZbCKKFr78t6wqchSRH5pVocpuPX3T3Ck/w7CMk89MTZP02GsXMzJ4wEKIcLrrne19Z3iGgTXIxNQJ3E+7M/E0NQrWeXRgN4cznhONhGS7I2E3V2TB4ygTsSYoWpA78WDMcGqakL2QWi1goX5wOrdATOnZMtR1SKHP/nSkpm3Z9jJxjufU8pXsw=
    - secure: W+BvS3DEpZh6oEQL0r0ZfCQy7VsukyQE+39VuKeqseQA5Fa9f7K0bB9X+iTt2EJGYpZx+QWX1z+mtmw1Mfp1q83w2jtf7n4ysyM4ttAlvR5lLKkgOhYBCYiwAb7WBknMck0ub2Nw6pf4NBlkJGvtcZWRfsefBqOHQh5mRh+gLMouSVj+p6mBPtvKdbH9z16cFm5KPBH32+7VAwRaNKsgY9Go4JG1DT5jt/2Et+rUfyeuK9DdRSnmdzjRvWLwpzHeaWGk2i92K04C+R9Ej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jYA4WNasnSqbvyIVKu1yeozVdGkAr+Myn0o=

matrix:
  fast_finish: true

before_install:
  - export JOBS=max
  - export PATH=./node_modules/.bin/:$PATH
  - npm install -g node-gyp
  - PUBLISH_BINARY=false
  - if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then PUBLISH_BINARY=true; fi;
  - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CC=gcc-4.8; export CXX=g++-4.8; fi

install:
  - npm install --build-from-source
  - npm test

before_script:
  - echo "Publishing native platform Binary Package? ->" $PUBLISH_BINARY
  - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package || true ; fi;
  - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp-github publish --release || true ; fi;
  - node-pre-gyp clean

script:
  - INSTALL_RESULT=0
  - if [[ $PUBLISH_BINARY == true ]]; then INSTALL_RESULT=$(npm install --fallback-to-build=false > /dev/null)$? || true; fi;
  - if [[ $INSTALL_RESULT != 0 ]]; then echo "returned $INSTALL_RESULT"; false; fi
  - node-pre-gyp clean

after_success:
  - node-pre-gyp info
