'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = searchFilesIgnoreExt;

var _ramda;

function _load_ramda() {
  return _ramda = _interopRequireDefault(require('ramda'));
}

var _vinyl;

function _load_vinyl() {
  return _vinyl = _interopRequireDefault(require('vinyl'));
}

var _fsNoExt;

function _load_fsNoExt() {
  return _fsNoExt = _interopRequireDefault(require('./fs-no-ext'));
}

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

function searchFilesIgnoreExt(files, fileName, returnProp) {
  var _byFileNoExt = function _byFileNoExt(file) {
    return (0, (_fsNoExt || _load_fsNoExt()).default)(file.relative) === (0, (_fsNoExt || _load_fsNoExt()).default)(fileName);
  };
  var _byFileWithExt = function _byFileWithExt(file) {
    return file.relative === fileName;
  };

  if (files && !(_ramda || _load_ramda()).default.isEmpty(files)) {
    var foundFile = (_ramda || _load_ramda()).default.find(_byFileWithExt, files) || (_ramda || _load_ramda()).default.find(_byFileNoExt, files);
    return foundFile && returnProp && foundFile[returnProp] ? foundFile[returnProp] : foundFile;
  }
  return null;
}