# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
  build:
    docker:
      - image: circleci/node:10.12-stretch

    working_directory: ~/node-7z

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: 
          name: Install System Dependencies
          command: sudo apt-get update && sudo apt-get install -y p7zip-full

      - run:
          name: Install Package Dependencies
          command: npm install

      - run:
          name: Install Code Climate, notify of a pending test report
          command: |
            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
            chmod +x ./cc-test-reporter
            ./cc-test-reporter before-build

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: 
          name: Run tests and coverage
          command: npm run coverage

      - run:
          name: Send coverage to Code Climate
          command: ./cc-test-reporter after-build --coverage-input-type lcov --exit-code $?

# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
  build:
    docker:
      - image: circleci/node:10.12-stretch

    working_directory: ~/node-7z

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "package.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: 
          name: Install System Dependencies
          command: sudo apt-get update && sudo apt-get install -y p7zip-full

      - run: 
          name: Copy 7z Binary to _mock
          command: cp /usr/bin/7z "./test/_mock/Seven Zip"
     
      - run:
          name: Install Package Dependencies
          command: npm install

      - run:
          name: Install Code Climate, notify of a pending test report
          command: |
            curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
            chmod +x ./cc-test-reporter
            ./cc-test-reporter before-build

      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: 
          name: Run tests and coverage
          command: npm run coverage

      - run:
          name: Send coverage to Code Climate
          command: ./cc-test-reporter after-build --coverage-input-type lcov --exit-code $?

Make 7z binary available for testing
ci: Make 7z binary available for testing
