"use strict";

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

var _fs = _interopRequireDefault(require("fs"));

var _ = require(".");

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

/**
 * Check if a folder to download course/Nanodegree has already exist
 * and prompt user if they want to overwrite this folder
 * @param {string} targetDir target directory
 * @param {string} dirName directory name of course/Nanodegree
 */
function checkOverwriteDir(targetDir, dirName) {
  const path = `${targetDir}/${dirName}`;

  if (_fs.default.existsSync(path)) {
    // prompt user if they want to overwrite this folder
    return (0, _.promptOverwriteDir)(dirName);
  }

  return new Promise(resolve => resolve(true));
}