#
# appveyor.xml from https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/master/appveyor.yml
#

os: unstable
environment:
  NODE_PRE_GYP_GITHUB_TOKEN:
    secure: T6VZrnLyvbW70lkzEcbpfEY9xEQbG0Jkp9vlblr9ixPcjMBsOiq3d6cTrxMSN0sW

  matrix:
  - nodejs_version: "4"
  - nodejs_version: "6"
  - nodejs_version: "7"
  - electron_version: "1.4.12"
    nodejs_version: "6"


platform:
- x86
- x64

install:
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform;
- ps: $env:Path += ";$(pwd)\node_modules\.bin";
- ps: npm install -g autogypi
- ps: npm install -g node-pre-gyp

- ps: >
    if ($env:plaftorm -eq "x86") {
      $env:npm_config_arch = "ia32"
    } else {
      $env:npm_config_arch = "x64"
    }
    true;

- ps: >
    if ($env:electron_version) {
      "We're an electron build, setup variables" | Write-Host
      $env:npm_config_target = $env:electron_version
      $env:npm_config_disturl = "https://atom.io/download/atom-shell"
      $env:npm_config_runtime = "electron"
      "Install electron and electron-mocha" | Write-Host
      npm install -g electron@$env:electron_version
    }
    true;

- 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
      "electron_version" = $env:electron_version
    } | Out-String | Write-Host;

- ps: npm config set -g cafile=package.json | Write-Host;
- ps: npm config set -g strict-ssl=false | Write-Host;

- ps: >
    npm config set progress false
    npm config set spin false

build_script:
- npm install --build-from-source

test_script:
- node-pre-gyp package 2>&1
- node-pre-gyp-github publish --release
- node-pre-gyp clean

deploy: OFF

matrix:
  fast_finish: true
