os: unstable

platform:
  #- x86
  - x64

configuration: Release

# don't re-build for tags so that [publish binary] is not re-run
skip_tags: true

# fix possible line-endings issues
init:
  - git config --global core.autocrlf input

build:
  parallel: true

environment:
  PUBLISH: 0
  NODE_PRE_GYP_GITHUB_TOKEN:
    secure: 3ufDq0gLKZ3ZthVup3MU4HdoHQ2KEShoQlZ8cDvjsjBQG1lvDSJCeqh1MGFdztFH

  matrix:
  # node
  - NVERSION: "4.6.0"
    RUNTIME: "node"
    RVERSION: "4.6.0"

  - NVERSION: "5.12.0"
    RUNTIME: "node"
    RVERSION: "5.12.0"

  - NVERSION: "6.5.0"
    RUNTIME: "node"
    RVERSION: "6.5.0"

  # electron
  - NVERSION: "4.6.0"
    RUNTIME: "electron"
    RVERSION: "0.37.8"

  - NVERSION: "4.6.0"
    RUNTIME: "electron"
    RVERSION: "1.2.3"


# get deps & setup arch
install:
  - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:NVERSION) $env:platform;
  - ps: $env:ARCH = $env:platform
  - ps: $env:Path += ";$(pwd)\node_modules\.bin";
  - ps: npm install npm -g
  - ps: node --version
  - ps: npm --version 

before_build:
  # work around an issue with node-gyp v3.3.1 and node 4x
  # package.json has no certificates in it so we're cool
  # https://github.com/nodejs/node-gyp/issues/921
  - ps: npm config set -g cafile=package.json | Write-Host;
  - ps: npm config set -g strict-ssl=false | Write-Host;

  # cleanup npm progress
  - ps: npm config set progress false | Write-Host;
  - ps: npm config set spin false | Write-Host;

build_script:
  - cmd: git submodule update --init
  - cmd: npm install --build-from-source --msvs_version=2015

test_script:
  # if we're publishing, do it
  - ps: >
      if ($env:APPVEYOR_REPO_COMMIT_MESSAGE -Match "[publish binary]") {
        "Publishing" | Write-Host
        $env:PUBLISH = "1"
      } else {
        "Not publishing" | Write-Host
      }

  - IF %PUBLISH% == 1 (node-pre-gyp --runtime=%RUNTIME% --target=%RVERSION% --target_arch=%ARCH% package 2>&1)
  - IF %PUBLISH% == 1 (node-pre-gyp-github publish --release 2>&1)
  - IF %PUBLISH% == 1 (node-pre-gyp clean 2>&1)

deploy: off

matrix:
  fast_finish: true