{"size": 2391, "ext": "js", "max_stars_repo_path": "gulp/tasks/scripts.js", "max_stars_repo_name": "roccojanse/quizr", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "gulp/tasks/scripts.js", "max_issues_repo_name": "roccojanse/quizr", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gulp/tasks/scripts.js", "max_forks_repo_name": "roccojanse/quizr", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.3108108108, "max_line_length": 80, "alphanum_fraction": 0.4968632371}
'use strict';

var config = require('../../config.js'),
    gulp = require('gulp'),
    gutil = require('gulp-util'),
    plumber = require('gulp-plumber'),
    del = require('del'),
    rename = require('gulp-rename'),
    sourcemaps = require('gulp-sourcemaps'),
    babel = require('gulp-babel'),
    concat = require('gulp-concat'),
    jshint = require('gulp-jshint'),
    uglify = require('gulp-uglify'),
    stripJs = require('gulp-strip-comments');     

module.exports = function() {

    gulp.task('scripts:compile', function(done) {

        var srcPath = config.srcPath + '/server',
            srcFiles = srcPath + '/**/*.js',
            destPath = config.destPath + '/server';

         // cleanup
        del.sync([destPath + '/**/*[.js,.js.map]']);

        gulp.src(srcFiles)
            .pipe(plumber(function(error) {
                gutil.log(error.message);
                this.emit('end');
            }))
            //.pipe(sourcemaps.init())
            .pipe(jshint())
            .pipe(jshint.reporter('jshint-stylish'))
            .pipe(babel({ presets: ['latest'] }))
            //.pipe(uglify({ mangle: false }))
            //.pipe(concat(fileName + '.js'))
            //.pipe(sourcemaps.write('.'))
            .pipe(gulp.dest(destPath))
            .on('end', done);       

    });

    gulp.task('scripts:build', function(done) {

        var srcPath = config.srcPath + '/public',
            srcFiles = srcPath + '/**/*.js',
            destPath = config.destPath + '/public/js';

        // cleanup
        del.sync([destPath +  '/' + config.clientFileName + '*[.js, .js.map]']);

        gulp.src(srcFiles)
            .pipe(plumber(function(error) {
                gutil.log(error.message);
                this.emit('end');
            }))
            .pipe(sourcemaps.init())
            .pipe(jshint())
            .pipe(jshint.reporter('jshint-stylish'))
            .pipe(babel({ presets: ['latest'] }))
            .pipe(uglify({ mangle: false }))
            .pipe(concat(config.clientFileName + '.js'))
            .pipe(rename({ suffix: '.min' }))
            .pipe(stripJs())
            .pipe(sourcemaps.write('.'))
            .pipe(gulp.dest(destPath))
            .on('end', done);
    });

    // gulp.task('scripts:watch', function() {
    //     gulp.watch(srcPath + '/**/*.js', ['scripts:build', 'server:reload']);
    // });
};