grunt-monty-python.js 1.55 KB
/*
 * grunt-monty-python
 *
 */

'use strict';

module.exports = function (grunt) {
    var _ = require('lodash');
    function createConfig(mpConfig) {

        var initConfig = {};
        var checkList = [];

        if (mpConfig.jshint) {
            grunt.loadNpmTasks('grunt-contrib-jshint');
            initConfig.jshint = {
                options: mpConfig.jshint.options,
                all: [
                    'Gruntfile.js',
                ],
                main: {
                    options: _.extend({}, mpConfig.jshint.browserOptions, {
                        globals: {
                            define: false,
                            require: false,
                        },
                    }),
                    files: {
                        src: [
                            'src/scripts/main.js',
                        ],
                    },
                }
            };
            checkList.push('jshint');
        }

        if (mpConfig.csslint) {
            grunt.loadNpmTasks('grunt-contrib-csslint');
            initConfig.csslint = {
            };
            checkList.push('csslint');
        }

        if (mpConfig.htmlmin) {
            grunt.loadNpmTasks('grunt-contrib-htmlmin');
            initConfig.htmlmin = {
            };
            checkList.push('htmlmin');
        }

        grunt.initConfig(initConfig);

        grunt.registerTask('check', checkList);

        grunt.registerTask('default', [
            'check',
        ]);

    }

    return {
        createConfig: createConfig,
    };
};