"use strict";

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

var _copyDir = _interopRequireDefault(require("copy-dir"));

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

var _rimraf = _interopRequireDefault(require("rimraf"));

var _utils = require("../../../utils");

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

/**
 * Create the root folder for the course
 * and copy CSS, JS assets to a folder
 * @param {string} outpath Path to put the course content
 * @param {string} courseName Name of the course
 * @returns {string} path to the course folder
 */
function makeRootDir(outpath, courseName) {
  // create root folder
  const dirRoot = (0, _utils.makeDir)(outpath, courseName);
  const dirAsset = (0, _utils.makeDir)(dirRoot, 'assets'); // remove dirAsset first if exist

  _rimraf.default.sync(dirAsset); // copy CSS, JS assets to target folder


  try {
    const dirAssetSource = _path.default.join(__dirname, '/../../templates/assets/');

    _copyDir.default.sync(dirAssetSource, dirAsset);
  } catch (error) {
    throw error;
  }

  return dirRoot;
}