'use strict';

const gulp = require('gulp');
const electron = require('electron-prebuilt');
const electronPackager = require('electron-packager');
var childProcess = require('child_process');

const packageJson = require('./package.json');

const _ = require('underscore');

const RELEASE_SETTINGS = {
    dir: '.',
    name: packageJson.name,
    out: 'dist',
    'app-version': '0.1.0',
    'version-string' : {
        ProductVersion : '0.1.0',
        ProductName : 'KongDash'
    },
    ignore : '/node_modules/(' + _.keys(packageJson.devDependencies).join('|') + ')',
    appPath : 'src/main.js',
    overwrite: true,
    asar: true,
    prune: true
};

require('gulp-task-list')(gulp);

gulp.task('start', (next) => {
    var child = childProcess.spawn(electron, ['./']);

    child.stdout.on('data', (data) => {
        console.log(data);
    });

    child.on('exit', (code) => {
        console.log('Child exited with code: ' + code);
        return next(code === 1 ? new Error('Error running run task') : null);
    });
});

gulp.task('build-linux', (next) => {
    electronPackager(_.extend(RELEASE_SETTINGS, {
        platform: 'linux',
        arch: 'all'
    }), next)
});

gulp.task('build-linux32', (next) => {
    electronPackager(_.extend(RELEASE_SETTINGS, {
        platform: 'linux',
        arch: 'ia32'
    }), next)
});

gulp.task('build-linux64', (next) => {
    electronPackager(_.extend(RELEASE_SETTINGS, {
        platform: 'linux',
        arch: 'x64'
    }), next)
});

gulp.task('build-win', (next) => {
    electronPackager(_.extend(RELEASE_SETTINGS, {
        platform: 'win32',
        arch: 'all',
        icon: 'resources/icons/kongdash-256x256.ico'
    }), next)
});
@@ -1033,160 +1033,8 @@
 );%0A%0A
-gulp.task('build-linux', (next) =%3E %7B%0A    electronPackager(_.extend(RELEASE_SETTINGS, %7B%0A        platform: 'linux',%0A        arch: 'all'%0A    %7D), next)%0A%7D);%0A
 %0Agul
@@ -1361,16 +1361,22 @@
 uild-win
+dows32
 ', (next
@@ -1374,32 +1374,32 @@
 2', (next) =%3E %7B%0A
-
     electronPack
@@ -1478,11 +1478,223 @@
 h: '
-all
+ia32',%0A        icon: 'resources/icons/kongdash-256x256.ico'%0A    %7D), next)%0A%7D);%0A%0Agulp.task('build-windows64', (next) =%3E %7B%0A    electronPackager(_.extend(RELEASE_SETTINGS, %7B%0A        platform: 'win32',%0A        arch: 'x64
 ',%0A 

build task for windows 32bit and windows 64bit