'use strict';

let childProcess = require('child_process');
let concat = require('gulp-concat');
let gulp = require('gulp');
let path = require('path');
let uglify = require('gulp-uglifyjs');

const SRC = 'client/js/libs/**/*.js';

gulp.task('uglify', function () {
    return gulp.src(SRC)
        .pipe(concat('libs.min.js'))
        .pipe(uglify({
            compress: false,
        }))
        .pipe(gulp.dest('client/dist/js/'));
});

gulp.task('build', function () {
    let handlebars = path.relative(__dirname, './node_modules/handlebars/bin/handlebars');
    let args = [
        String(handlebars),
        'client/views/',
        '-e', 'tpl',
        '-f', 'client/dist/js/shout.templates.js',
    ];

    let option = {
        cwd: path.relative(__dirname, ''),
        stdio: 'inherit',
    };
    childProcess.spawn('node', args, option);
});

gulp.task('default', ['uglify', 'build']);

gulp.task('watch', ['uglify'], function () {
    gulp.watch(SRC, ['uglify']);
});

@@ -197,16 +197,22 @@
 st SRC =
+ %5B%0A   
  'client
@@ -224,16 +224,379 @@
 ibs/
-**/*.js'
+favico.js',%0A    'client/js/libs/handlebars.js',%0A    'client/js/libs/handlebars/**/*.js',%0A    'client/js/libs/jquery.js',%0A    'client/js/libs/jquery/**/*.js',%0A    'client/js/libs/moment.js',%0A    'client/js/libs/notification.js',%0A    'client/js/libs/socket.io.js',%0A    'client/js/libs/string.contains.js',%0A    'client/js/libs/stringcolor.js',%0A    'client/js/libs/uri.js',%0A%5D
 ;%0A%0Ag
@@ -657,45 +657,8 @@
 RC)%0A
-        .pipe(concat('libs.min.js'))%0A
     
@@ -674,16 +674,31 @@
 (uglify(
+'libs.min.js', 
 %7B%0A      

Fix regression by 0a8752448f19d93b4fdd1bea837611647ea7fae4.