'use strict';

var gulp = require('gulp'),
    doLint = require('./lintWorker.js'),
    gutil        = require('gulp-util');

var m = require('../common.js');
var buildConfig = m.config.buildConfig;

m.lintGlob = [buildConfig.clientAppDir + '/scripts/**/*.js',
    './client/test/**/*.js',
    './client/ruleengine/**/*.js',
    buildConfig.serverDir + '/**/*.js',
    './shared/**/*.js',
    './gulp/**/*.js',
    '!' + buildConfig.serverDir + '/public/**',
    '!' + buildConfig.serverDir + '/private/**'
    ];

gulp.task('lint',
    done => {
        doLint.doLinting(m.lintGlob,
            function success(){
                gutil.log('eslint success');
                done();
            }, function error(){
                gulp.fail = true;
                doLint.lintErrMessage();
                process.exit(1);
            });
    });