environment:
  nodejs_version: "8"
  prebuild_upload:
    secure: hjViAyQNSlczp/ZOQ3UEhvQohKEtrkbEa3DJ1Zy7z2gTz4aFcoxARRlIqUFZMEnO

  matrix:
  - nodejs_version: "4"
  - nodejs_version: "6"
  - binary_builder: "true"
    nodejs_version: "8"

platform:
  - x86
  - x64

cache:
  - '%APPDATA%\npm'
  - '%APPDATA%\npm-cache'

install:
- ps: Install-Product node $env:nodejs_version $env:platform
- ps: >
    @{
      "nodejs_version" = $env:nodejs_version
      "platform" = $env:platform
      "node binary version" = $(node -v)
      "node platform@arch" = $(node -p 'process.platform + process.arch')
      "npm version" = $(npm -v)
      "APPVEYOR_REPO_COMMIT_MESSAGE" = $env:APPVEYOR_REPO_COMMIT_MESSAGE
      "git latest tag" = "$(git describe --tags --always HEAD)"
      "appveyor_repo_tag" = $env:appveyor_repo_tag
    } | Out-String | Write-Host;
- npm install

# Check if we're building the latest tag, if so
# then we publish the binaries if tests pass.
- ps: >
    if ($env:appveyor_repo_tag -match "true" -and ("$(git describe --tags --always HEAD)" -eq $env:appveyor_repo_tag_name)) {
      $env:publish_binary = $env:binary_builder;
    }
    if ($env:publish_binary -eq "true") {
      "We're publishing a binary!" | Write-Host
    } else {
      "We're not publishing a binary" | Write-Host
    }
    true;

build_script:
- npm install --build-from-source

test_script:
# Tests are disabled until we have tests which are suitable for CI and don't require manual interaction.
# - npm test
- echo "Skipping tests on CI, as they currently require manual interaction."

- ps: >
    if ($env:publish_binary -eq "true") {
      npm run prebuild
    }
    true;

deploy: OFF
