 cp = require 'child_process'
 async = require 'async'
 asar = require 'asar'
+path = require 'path'
 del = require 'del'
 
 gulp = require 'gulp'

        '.'
      ]

      cp.exec 'fpm ' + args.join(' '), done

# Create the win32 installer; only works on Windows
gulp.task 'pack:win32:installer', ['build:win32', 'clean:dist:win32'], ->
  if process.platform isnt 'win32'
    return console.warn 'Skipping win32 installer packing; This only works on Windows due to Squirrel.Windows.'


    if not process.env[envName]
      return console.warn envName + ' env var not set.'

  async.series [
    # First, compress the source files into an asar archive
    async.apply asar.createPackage, './build/win32/resources/app', './build/win32/resources/app.asar'

    # Remove leftovers
    async.apply del, './build/win32/resources/app'

    # Create the installer
    (callback) ->
      winInstaller
        appDirectory: './build/win32'
        outputDirectory: './dist'
        loadingGif: './build/resources/win/install-spinner.gif'
        certificateFile: process.env.SIGN_WIN_CERTIFICATE_FILE
        certificatePassword: process.env.SIGN_WIN_CERTIFICATE_PASSWORD
        setupIcon: './build/resources/win/setup.ico'
        iconUrl: 'https://raw.githubusercontent.com/Aluxian/electron-superkit/master/resources/win/app.ico'
        remoteReleases: manifest.repository.url
      .then callback, callback
  ], done

# Create the win32 portable zip
gulp.task 'pack:win32:portable', ['build:win32', 'clean:dist:win32'], (done) ->
