Source: tasks/html/remove.js

'use strict';

/**
 * @module tasks/html/remove
 */

/**
 * taskFactory
 * @param sources {Array} glob
 * @param options {Object}
 * @returns task {Function}
 */
module.exports = function taskFactory(sources, options) {

    return function task() {

        var gulp = require('gulp');
        var removeCode = require('gulp-remove-code');
        var destinationsHelper = require('../helpers/build-destinations');
        var destination;

        if (options && options.destination) {
            destination = options.destination;
        }

        var removeCodeOpts = {
            production: true
        };

        return gulp.src(sources)
            .pipe(removeCode(removeCodeOpts))
            .pipe(gulp.dest(function (file) {
                return destinationsHelper.getDestination(file.base, destination);
            }));
    };
};