module.exports = function RegExpPlugin (regexp, propName) {
    // TODO if regexp is global
    //  then data[name2].abc = []
    // else data[name2].abc = null;
    // this is inconsistent.

    return {
        readFile: function (fs, fileName) {
                var res = {
                    file: fileName,
                };
                var content = fs.readFileSync(fileName, 'utf8');

                var match;
                var matches = [];
                if (regexp.global) {
                    while (match = regexp.exec(content)) {
                        matches.push(match);
                    }
                } else {
                    matches = regexp.exec(content);
                }
                res[propName] = matches;
                return res;
        }
    }
};

var _ = require('lodash');

module.exports = function RegExpPlugin (regexp, propName, options) {
    // TODO if regexp is global
    //  then data[name2].abc = []
    // else data[name2].abc = null;
    // this is inconsistent.
    options = options || {};

    return {
        readFile: function (fs, fileName) {
                var res = {
                    file: fileName,
                };
                var content = fs.readFileSync(fileName, 'utf8');

                var match;
                var matches = [];
                if (regexp.global) {
                    while (match = regexp.exec(content)) {
                        matches.push(match);
                    }
                } else {
                    matches = regexp.exec(content);
                }

                // removes duplicates in according to first (0) part of matches
                // this could change in the future
                res[propName] = options.removeDuplicates? _.uniq(matches, 0) : matches;
                return res;
        }
    }
};

add removeDuplicates option in RegExpPlugin