"use strict";

var _postcss = _interopRequireDefault(require("postcss"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

module.exports = _postcss.default.plugin('postcss-exclude-files', opts => {
  const {
    plugins
  } = opts;
  return (root, result) => {
    const inputFile = root.source.input.file;
    const isIgnoredFile = opts.ignore.some(file => inputFile.indexOf(file) !== -1);

    if (!isIgnoredFile) {
      const handler = response => response.messages.forEach(msg => result.messages.push(msg));

      return (0, _postcss.default)(plugins).process(root, {
        from: undefined
      }).then(handler);
    }
  };
});