# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2

aliases:
  x-ignore-master: &x-ignore-master
    filters:
      branches:
        ignore: master

  x-only-master: &x-only-master
    filters:
      branches:
        only: master


jobs: 
  lint:
    docker:
      - image: circleci/node:8.9
    steps:
      - checkout
      - restore_cache:
          keys:
          - npm-{{ checksum "package-lock.json" }}-{{ arch }}
          - npm-
      - run: npm install
      - save_cache:
          paths:
            - node_modules
          key: npm-{{ checksum "package-lock.json" }}-{{ arch }}
      - run:
          command: |
            LAST_TAG=`git describe --tags --abbrev=0`
            echo commitlint --from ${LAST_TAG}
            npx commitlint --from ${LAST_TAG}  


workflows:
  version: 2
  pullrequest:
    jobs:
      - lint:
          <<: *x-ignore-master

  master: 
    jobs: 
      - lint:
          <<: *x-only-master