language: node_js
dist: trusty
sudo: false
node_js:
  - "5"

before_install:
  - "export DISPLAY=:99.0"
  - "sh -e /etc/init.d/xvfb start"

env:
  matrix:
    - MODULE=ng2-alfresco-core
    - MODULE=ng2-alfresco-datatable
    - MODULE=ng2-alfresco-documentlist
    - MODULE=ng2-alfresco-login
    - MODULE=ng2-alfresco-search
    - MODULE=ng2-alfresco-upload
    - MODULE=ng2-alfresco-viewer
    - MODULE=ng2-alfresco-webscript
    - MODULE=ng2-alfresco-tag
    - MODULE=ng2-activiti-form
    - MODULE=ng2-activiti-tasklist
    - MODULE=ng2-activiti-processlist
    - MODULE=ng2-activiti-diagrams
    - MODULE=ng2-activiti-analytics
    - MODULE=ng2-alfresco-userinfo

before_script:
  - if ([ "$MODULE" != "ng2-alfresco-core" ]); then
        (cd ng2-components/ng2-alfresco-core; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
    fi
  - if ([ "$MODULE" == "ng2-alfresco-documentlist" ] || [ "$MODULE" == "ng2-alfresco-webscript" ] || [ "$MODULE" == "ng2-activiti-processlist" ] || [ "$MODULE" == "ng2-activiti-tasklist" ]); then
        (cd ng2-components/ng2-alfresco-datatable; npm link ng2-alfresco-core; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
    fi
  - if ([ "$MODULE" == "ng2-activiti-tasklist" ] || [ "$MODULE" == "ng2-activiti-processlist" ]); then
        (cd ng2-components/ng2-alfresco-datatable; npm link ng2-alfresco-core; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
        (cd ng2-components/ng2-activiti-form; npm link ng2-alfresco-core; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
    fi
  - if ([ "$MODULE" == "ng2-activiti-processlist" ]); then
        (cd ng2-components/ng2-alfresco-datatable; npm link ng2-alfresco-core; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
        (cd ng2-components/ng2-activiti-form; npm link ng2-alfresco-core; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
        (cd ng2-components/ng2-activiti-tasklist; npm link ng2-alfresco-core; npm link ng2-alfresco-datatable; npm link ng2-activiti-form; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
    fi
  - if ([ "$MODULE" == "ng2-activiti-analytics" ]); then
        (cd ng2-components/ng2-activiti-diagrams; npm link ng2-alfresco-core; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
    fi
  - if ([ "$MODULE" == "ng2-alfresco-search" ]); then
        (cd ng2-components/ng2-alfresco-datatable; npm link ng2-alfresco-core; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
        (cd ng2-components/ng2-alfresco-documentlist; npm link ng2-alfresco-core; npm link ng2-alfresco-datatable; if [ ! -d "bundles" ]; then npm install && npm run  build && npm link; fi);
    fi
  - cd ng2-components/$MODULE;
script: npm install && npm run travis && npm run test
# Send coverage data to Coveralls
after_success:
  bash <(curl -s https://codecov.io/bash) -X gcov

cache:
  directories:
  - ./node_modules/material-design-lite
  - ./node_modules/material-design-icons
  - demo-shell-ng2/node_modules
  - ng2-components/ng2-activiti-form/node_modules
  - ng2-components/ng2-activiti-processlist/node_modules
  - ng2-components/ng2-activiti-tasklist/node_modules
  - ng2-components/ng2-alfresco-core/node_modules
  - ng2-components/ng2-alfresco-datatable/node_modules
  - ng2-components/ng2-alfresco-documentlist/node_modules
  - ng2-components/ng2-alfresco-login/node_modules
  - ng2-components/ng2-alfresco-search/node_modules
  - ng2-components/ng2-alfresco-upload/node_modules
  - ng2-components/ng2-alfresco-viewer/node_modules
  - ng2-components/ng2-alfresco-webscript/node_modules
  - ng2-components/ng2-alfresco-tag/node_modules
  - ng2-components/ng2-activiti-analytics/node_modules
  - ng2-components/ng2-alfresco-userinfo/node_modules
  - ng2-components/ng2-activiti-diagrams/node_modules
