(function () {
    var gulp = require('gulp'),
        util = require('gulp-util'),
        open = require('gulp-open'),
        shell = require('gulp-shell');

    //Consts
    const PLUGIN_NAME = 'gulp-iis-express';

    //main gulp plugin function
    function gulpIISExpress(config){

        if(!config){
            throw new util.PluginError(PLUGIN_NAME, "Config file is missing!");
        }
        if(!config.configFile){
            config.configFile = "";
        }
        if(!config.sitePaths){
            config.sitePaths = [];
        }
        if(!config.appPools){
            config.appPools = [];
        }
        if(!config.startUrl || config.startUrl == ""){
            throw new util.PluginError(PLUGIN_NAME, "StartUrl must be provided");
        }
        if(!config.browser || config.browser == ""){
            config.browser = "chrome";
        }
        if(!config.iisExpressPath || config.iisExpressPath == ""){
            config.iisExpressPath = "C:\\Program Files (x86)\\IIS Express"
        }
        return gulp.src('/index.html')
            .pipe(open('', {
                url: config.startUrl,
                app: config.browser
            }))
            .pipe(startSites(config))
            .on('error', util.log);
    }

    //starting the sites.
    function startSites(config){

        config.sitePaths.forEach(function(item){
            var cmd = 'iisexpress /site:"'  + item + '"';

            if(config.configFile !== ""){
                cmd += '/configFile:"' + config.configFile + '"';
            }

            gulp.src('')
                .pipe(shell([
                    cmd
                ],{
                    cwd: config.iisExpressPath
                }))
                .on('error', util.log);
        });

        config.appPools.forEach(function(item){
            var cmd = 'iisexpress /apppool:"' + item + '"';

            if(config.configFile !== ""){
                cmd += '/configFile:"' + config.configFile + '"';
            }

            gulp.src('')
                .pipe(shell([
                    cmd
                ],{
                    cwd: config.iisExpressPath
                }))
                .on('error', util.log);
        });

        return gulp.src('');
    }

    //Exporting the plugin main function
    module.exports = gulpIISExpress;
})();

@@ -613,32 +613,42 @@
 = %5B%5D;%0A        %7D%0A
+        %7D%0A
         if(!conf
@@ -654,42 +654,412 @@
 fig.
-startUrl %7C%7C config.startUrl == %22%22)
+iisExpressPath %7C%7C config.iisExpressPath == %22%22)%7B%0A            config.iisExpressPath = %22C:%5C%5CProgram Files (x86)%5C%5CIIS Express%22%0A        %7D%0A        return gulp.src('/index.html')%0A            .pipe(startSites(config))%0A            .on('error', util.log);%0A    %7D%0A    %0A    //launch browser helper function%0A    gulpIISExpress.launchBrowser = function(config)%7B%0A        %0A        // Default options%0A        if (!config) 
 %7B%0A  
@@ -1113,33 +1113,40 @@
 E, %22
-StartUrl must be provided
+Missing config for launchBrowser
 %22);%0A
@@ -1157,32 +1157,33 @@
     %7D%0A        if
+ 
 (!config.browser
@@ -1175,23 +1175,24 @@
 !config.
-browser
+startUrl
  %7C%7C conf
@@ -1194,23 +1194,24 @@
  config.
-browser
+startUrl
  == %22%22)%7B
@@ -1227,33 +1227,76 @@
     
-config.browser = %22chrome%22
+throw new util.PluginError(PLUGIN_NAME, %22startUrl must be provided%22)
 ;%0A  
@@ -1305,32 +1305,33 @@
     %7D%0A        if
+ 
 (!config.iisExpr
@@ -1327,130 +1327,80 @@
 fig.
-iisExpressPath %7C%7C config.iisExpressPath == %22%22)%7B%0A            config.iisExpressPath = %22C:%5C%5CProgram Files (x86)%5C%5CIIS Express%22
+browser %7C%7C config.browser == %22%22)%7B%0A            config.browser = %22chrome%22;
 %0A   
@@ -1568,46 +1568,8 @@
 %7D))%0A
-            .pipe(startSites(config))%0A
     

move browser launch to dedicated function