version: '{build}'

platform:
  - x64

services:
  - mssql2016

shallow_clone: true

cache:
  - node_modules

environment:
  matrix:
    - {NODE_VERSION: 0.10,   DIALECT: mssql}
    - {NODE_VERSION: 0.12,   DIALECT: mssql, COVERAGE: true}

install:
  - ps: Install-Product node $env:NODE_VERSION x64
  - ps: |
      $pkg = ConvertFrom-Json (Get-Content -Raw package.json)
      $pkg.devDependencies.PSObject.Properties.Remove('sqlite3')
      $pkg.devDependencies.PSObject.Properties.Remove('pg-native')
      ConvertTo-Json $pkg | Out-File package.json -Encoding UTF8
  - npm install

build: off

before_test:
  - ps: . .\appveyor-setup.ps1

test_script:
  - 'IF "%COVERAGE%" == "true" (npm run cover) ELSE (npm test)'

after_test:
  - ps: |
      $env:PATH = 'C:\Program Files\Git\usr\bin;' + $env:PATH
      if (Test-Path env:\COVERAGE) {
        Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
        bash codecov.sh -f "coverage\lcov.info"
      }

branches:
  only:
    - master
    - v3
