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  PROJECT_PATH: "$CI_PROJECT_DIR"
  APP_OUTPUT_PATH: "$CI_PROJECT_DIR/artifacts/app"

cache:
  paths:
  - node_modules/
  - client/node_modules/
  - server/node_modules/

install:
  stage: install
  script:
    - npm --silent install
    - cd server && npm --silent install
    - cd ../client && npm --silent install
  only:
    changes:
      - package-lock.json
    refs:
      - master
      - merge_requests

build:
  stage: build
  artifacts:
    name: "angular-app-pipeline"
    paths:
      - $APP_OUTPUT_PATH
  script:
    - npm build
  only:
    refs:
      - master
      - merge_requests

server_test:
  stage: test
  script:
    - cd server && npm test
  only:
    refs:
      - master
      - merge_requests