image: node:latest
stages:
  - init
  - test
  - publish 
install_dependencies:
  stage: init
  script:
    - npm install
  artifacts:
    paths:
      - node_modules/
    expire_in: 15 minutes
  dependencies: []  
unit-test-master:
  only:
    - master
  stage: test
  allow_failure: false
  script:
    - npm install nyc -g
    - npm run coverage
  dependencies:
    - install_dependencies
unit-test-other-branches:
  except:
    - master
  stage: test
  allow_failure: true
  script:
    - npm install nyc -g
    - npm run coverage
  dependencies:
    - install_dependencies
publish:
  only:
    - master
  stage: publish
  allow_failure: false
  script:
    - echo $'@eplata:registry=https://registry.npmjs.org/\n//registry.npmjs.org/:_authToken=${NPM_AUTH_KEY}'>.npmrc
    - npm publish --tag=latest
  dependencies:
    - install_dependencies
