"use strict";

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

var _prettier = _interopRequireDefault(require("prettier"));

var _importFrom = _interopRequireDefault(require("import-from"));

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

/**
 * Returns the prettier module from either coat's
 * dependencies or the local prettier version of
 * the current coat context if prettier is available.
 *
 * @param context The current coat context if available
 */
function getPrettier(context) {
  let prettier = _prettier.default;

  if (context) {
    const prettierLocal = _importFrom.default.silent(context.cwd, "prettier");

    if (prettierLocal) {
      prettier = prettierLocal;
    }
  }

  return prettier;
}