# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
defaults: &defaults
  working_directory: ~/workspace
  docker:
    - image: circleci/node:latest

lint: &lint
  name: Lint
  command: npm run ci-lint

test: &test
  name: Test
  command: npm run ci-test

coverage: &coverage
  name: Coverage
  command: npm run ci-cov

build_and_test: &build_and_test
  - checkout

  - run:
      name: Version check
      command: node -v

  - run:
     name: Update dependencies
     command: |
       npm config set package-lock false
       npm update --save-dev # https://github.com/npm/npm/issues/16901
       npm update

  - run: *lint

  - run: *test

  - run: *coverage

jobs:
  node-v8:
    <<: *defaults
    docker:
      - image: node:8
    steps: *build_and_test

  node-v10:
    <<: *defaults
    docker:
      - image: node:10
    steps: *build_and_test

workflows:
  version: 2
  node-multi-build:
    jobs:
      - node-v8
      - node-v10
