version: 2
jobs:
  build:
    docker:
      - image: 'circleci/node:latest'
    steps:
      - checkout
      - restore_cache:
          key: npm-deps-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
      - run:
          name: Install dependencies
          command: npm install
      - save_cache:
          key: npm-deps-{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - run:
          name: Lint
          command: npm run lint
      - run:
          name: Detect circular dependencies
          command: npm run circular
      - run:
          name: Unit tests
          command: npm run test
      - run:
          name: Build
          command: npm run build
