"use strict";

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

var _fsExtra = _interopRequireDefault(require("fs-extra"));

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

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

/**
 * Read a template file
 * @param {string} name name of template file
 */
async function loadTemplate(name) {
  const dirAppRoot = _path.default.resolve(__dirname);

  const dirTemplates = _path.default.resolve(dirAppRoot, '../../templates');

  const pathTemplateHtml = _path.default.resolve(dirTemplates, `${name}.html`);

  try {
    const content = _fsExtra.default.readFile(pathTemplateHtml, 'utf-8');

    return content;
  } catch (error) {
    throw error;
  }
}