language: node_js
node_js:
  - lts/*
install:
  - yarn install
cache:
  directories:
    - node_modules
script:
  - yarn ci
  - yarn docs:build

#after_success:
#  - npm run codecov

before_deploy: |
  function npm_dist_tag() {
    if [[ "$TRAVIS_TAG" = *"-"* ]]; then
      echo "next"
    else
      echo "latest"
    fi
  }

deploy:
  - edge: true
    provider: npm
    email: kuitos.lau@gmail.com
    api_key: $NPM_AUTH_TOKEN
    skip_cleanup: true
    on:
      tags: true
    tag: $(npm_dist_tag)

  - provider: pages
    skip_cleanup: true
    local_dir: dist
    github_token: $GITHUB_TOKEN
    keep_history: true
    on:
      branch: master
