"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

function _ramda() {
  const data = _interopRequireDefault(require("ramda"));

  _ramda = function () {
    return data;
  };

  return data;
}

function _vinyl() {
  const data = _interopRequireDefault(require("vinyl"));

  _vinyl = function () {
    return data;
  };

  return data;
}

function _fsNoExt() {
  const data = _interopRequireDefault(require("./fs-no-ext"));

  _fsNoExt = function () {
    return data;
  };

  return data;
}

function searchFilesIgnoreExt(files, fileName, returnProp) {
  const _byFileNoExt = file => (0, _fsNoExt().default)(file.relative) === (0, _fsNoExt().default)(fileName);

  const _byFileWithExt = file => file.relative === fileName;

  if (files && !_ramda().default.isEmpty(files)) {
    const foundFile = _ramda().default.find(_byFileWithExt, files) || _ramda().default.find(_byFileNoExt, files);

    return foundFile && returnProp && foundFile[returnProp] ? foundFile[returnProp] : foundFile;
  }

  return null;
}