const path = require('path');
const utils = require('./utils');

module.exports.start = (options) => {
  return Promise.resolve()
    .then(() => {
      return postBuild(options.config, options.targetPath,)
    })
    .catch((e) => {
      throw e;
    })
}

const postBuild = (cliConfig, targetPath) => {
  const appName = cliConfig.appName;
  const appType = cliConfig.appType;
  const artifactId = cliConfig.artifactId;

  console.log(`Post build`);

  return Promise.resolve()
    .then(() => {
      console.log('--renaming .gitignore');
      const angularPath = utils.getAngularPath(targetPath, appName, appType, artifactId);
      return utils.move(path.join(angularPath, 'gitignore_TO_REPLACE'), path.join(angularPath, '.gitignore'));
    })

    .catch((e) => {
      throw e;
    })
}
