const fs = require('fs');
const path = require('path');
const handlebars = require('handlebars');
const packageJson = require('../package');

function compile() {
  const templatePath = path.resolve(__dirname, 'index.html.handlebars');
  const template = fs.readFileSync(templatePath).toString();
  const delegate = handlebars.compile(template);
  const data = {
    appBundle: './bundle.js',
    appTitle: packageJson.productName,
  };

  return delegate(data);
}

exports.compile = compile;
