'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

function updateManifestCore(_ref) {
  var path = _ref.path,
    value = _ref.value,
    manifest = _ref.manifest;
  var arr = path.split('.');
  var len = arr.length;
  var lastItem = arr[len - 1];
  var i = 0;
  var manifestArr = manifest.split(/\n/);
  for (var index = 0; index < manifestArr.length; index++) {
    var item = manifestArr[index];
    if (new RegExp("\"".concat(arr[i], "\"")).test(item)) i = i + 1;
    if (i === len) {
      var hasComma = /,/.test(item);
      manifestArr[index] = item.replace(new RegExp("\"".concat(lastItem, "\"[\\s\\S]*:[\\s\\S]*")), "\"".concat(lastItem, "\": ").concat(value).concat(hasComma ? ',' : ''));
      break;
    }
  }
  return manifestArr.join('\n');
}

exports.updateManifestCore = updateManifestCore;
