"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _fs = require("fs");
var _path = require("path");
var _deepmerge = _interopRequireDefault(require("../compiled/deepmerge"));
var _prettier = _interopRequireDefault(require("../compiled/prettier"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function updatePackageJSON({
  opts,
  cwd = process.cwd()
}) {
  const packageJsonPath = (0, _path.resolve)(cwd, 'package.json');
  const pkg = require(packageJsonPath);
  const projectPkg = (0, _deepmerge.default)(pkg, opts);
  (0, _fs.writeFileSync)(packageJsonPath,
  // 删除一个包之后 json会多了一些空行。sortPackage 可以删除掉并且排序
  // prettier 会容忍一个空行
  _prettier.default.format(JSON.stringify(projectPkg), {
    parser: 'json'
  }));
}
var _default = updatePackageJSON;
exports.default = _default;