/**
 * Generate Sitelogo based on src/settings passed
 */
module.exports = function(gulp, projectPath, themePath, config) {
    var TASK_NAME = 'sitelogo';

    return {
        name: TASK_NAME,
        task: function getSiteLogoTask(done) {
            var _subTasks = [],
                imagemin = require('gulp-imagemin'),
                merge = require('merge-stream');

            _subTasks.push(
                gulp.src(
                    config.src.map(function (item) {
                        return themePath + item;
                    }),
                    {
                        cwd: projectPath,
                        allowEmpty: true
                    })
                .pipe( imagemin() )
                .pipe(gulp.dest(
                    themePath + config.dest,
                    { cwd: projectPath }
                ))
            );

            return merge(_subTasks);
        },
        setProjectPath: function (path) {
            projectPath = path;
        },
        setThemePath: function (path) {
            themePath = path;
        }
    }
};

