# This is a sample build configuration for Javascript (Node.js).
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:8.9.3

pipelines:
  branches:
    master:
      - step:
          deployment: production
          script:
          # Generates a .npmrc file configured for installing private modules:
          #
          # NPM_REGISTRY_URL: the full URL of your private registry
          #                   defaults to registry.npmjs.org.
          # NPM_TOKEN: secret token for installing private modules. This
          #            this token can be found in your .npmrc, after logging in.
            - printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
            - npm install
            - npm test
            - npm publish
    dev:
      - step:
          deployment: staging
          script:
            - npm install
            - npm test