---
machine:
  environment:
    PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
  node:
    version: 8.2.0

dependencies:
  override:
    - yarn global add codecov
    - yarn install --no-progress --no-emoji --ignore-engines
  cache_directories:
    - "node_modules"
    - ~/.yarn
    - ~/.yarn-cache

test:
  override:
    - yarn lint
    # TODO: - yarn flow
    - yarn run test -- --coverage
    - codecov

deployment:
  release:
    tag: /v[0-9]+(\.[0-9]+)*/
    commands:
      - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
      - yarn publish --new-version `./scripts/version.js`