version: 2
jobs:
  build-node8:
    docker:
      - image: node:8
    working_directory: ~/w
    steps:
      - checkout
      - run: yarn global add gulp cypress-cli
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run: yarn install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run: yarn tslint
      - run: yarn test
      - run: yarn cleanupBuild
      - run: yarn compile
      - deploy:
          name: publish to npmjs.com
          command: scripts/publish
  build-node6:
    docker:
      - image: node:6
    working_directory: ~/w
    steps:
      - checkout
      - run: yarn global add gulp cypress-cli
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run: yarn install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - ./node_modules
      - run: yarn tslint
      - run: yarn test
      - run: yarn cleanupBuild
      - run: yarn compile

workflows:
  version: 2
  build:
    jobs:
      - build-node8:
          requires:
            - build-node6
      - build-node6
