"use strict";

var fs              = require("fs");
var pkg             = require("./package.json");
var headerTemplate  = fs.readFileSync("header.txt");
var headerVars      = {
    name            : "LoadingOverlay",
    author          : "Gaspare Sganga",
    description     : pkg.description,
    version         : pkg.version,
    license         : pkg.license,
    documentation   : pkg.homepage
};

var paths = {
    src     : "src/",
    dest    : "dist/"
}

var gulp        = require("gulp");
var del         = require("del");
var inquirer    = require("inquirer");
var rename      = require("gulp-rename");
var replace     = require("gulp-replace");
var header      = require("gulp-header");
var sourcemaps  = require("gulp-sourcemaps");
var uglify      = require("gulp-uglify");
var cleanCSS    = require("gulp-clean-css");


function src_headers(){
    return gulp.src([paths.src + "*.js", paths.src + "*.css"])
        .pipe(replace(/^\/\*{119}[^*]+\*{119}\/(\r\n|\r|\n)/, ""))
        .pipe(header(headerTemplate, headerVars))
        .pipe(gulp.dest(paths.src));
}


function dist_clean(){
    return del([paths.dest + "*"]);
}

function dist_js(){
    return gulp.src(paths.src + "*.js")
        .pipe(gulp.dest(paths.dest))
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(header(headerTemplate, headerVars))
        .pipe(rename({
            extname : ".min.js"
        }))
        .pipe(sourcemaps.write("./", {
            addComment : false
        }))
        .pipe(gulp.dest(paths.dest));
}

function dist_css(){
    return gulp.src(paths.src + "*.css")
        .pipe(gulp.dest(paths.dest))
        .pipe(cleanCSS())
        .pipe(header(headerTemplate, headerVars))
        .pipe(rename({
            extname : ".min.css"
        }))
        .pipe(gulp.dest(paths.dest));
}


gulp.task("default", function(){
    return inquirer.prompt([{
        type        : "list",
        name        : "task",
        message     : "Select the task to run",
        choices     : [
            {
                name    : "Update source headers",
                value   : "src"
            },
            {
                name    : "Update dist",
                value   : "dist"
            },
            {
                name    : "Exit",
                value   : "exit"
            }
        ],
        pageSize    : "3"
    }]).then(function(ret){
        switch (ret.task) {
            case "src":
                gulp.parallel(src_headers)();
                break;
                
            case "dist":
                gulp.series(dist_clean, gulp.parallel(dist_js, dist_css))();
                break;
            
            default:
                console.log("\nNothing done\n");
        }
    });
});
@@ -198,22 +198,26 @@
  : %22
-LoadingOverlay
+jQuery Message Box
 %22,%0A 
@@ -2757,8 +2757,9 @@
  %7D);%0A%7D);
+%0A

Change File header name to jQuery Message box.