/**
 * Expand glob pattern with ignore options.
 * @function task.worker._expandGlobUnlessIgnored
 * @param {string} pattern - File name pattern.
 * @param {string} ignore - Patterns to ignore.
 * @param {function} callback - Callback with expanded.
 * @protected
 * @ignore
 * @author Taka Okunishi
 */

var file = require('../../lib/file'),
    expandGlob = file.expandGlob,
    ignoreFilter = file.ignoreFilter;

module.exports = function (pattern, ignore, callback) {
    expandGlob(pattern, function (err, filenames) {
        if (err) {
            callback(err);
            return;
        }
        callback && callback(
            null,
            filenames.filter(ignoreFilter(ignore))
        );
    });
};