"use strict";

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

var _path = _interopRequireDefault(require("path"));

var _removeHashFromFileName = require("./removeHashFromFileName");

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

function addFilesNamesToManifestJson({
  manifestJson,
  option,
  assets,
  hashDigestLength
}) {
  const json = manifestJson;
  Object.keys(assets).forEach(filename => {
    const fileName = _path.default.parse(filename).base;

    if (option.test(filename)) {
      const filenameNameWithoutHash = (0, _removeHashFromFileName.removeHashFromFileName)(fileName, hashDigestLength);
      json[filenameNameWithoutHash] = fileName;
    }
  });
  return json;
}