<commit_before>'use strict';

const colors = require('colors'),
  shell = require('shelljs/global'),
  fs = require('fs'),
  emoji = require('node-emoji'),
  del = require('del'),
  copydir = require('copy-dir'),
  noEmoji = /^win/.test(process.platform);

if (noEmoji) {
  emoji.get = () => '';
}

let config = {},
  configClass = require('./config')({
    fs: fs,
    del: del
  }),
  git = require('./git')({
    folderExists: folderExists,
    logComplete: logComplete,
    del: del,
    emoji: emoji
  }),
  dependencies = require('./dependencies')({
    errorMessage: errorMessage,
    logComplete: logComplete,
    fs: fs
  }),
  vendor = require('./vendor')({
    errorMessage: errorMessage,
    fs: fs
  });

/**
 * Output "Complete" message
 * @function
 */
function logComplete(task) {
  console.log('['.green + task.green + ' ' + emoji.get('white_check_mark') + ' ]\n'.green);
}

/**
 * Output "Error" message
 * @function
 */
function errorMessage(e) {
  console.log(`Error: ${e}`.red);
}

/**
 * Check if the folder exists
 * @function
 */
function folderExists(src) {
  return fs.existsSync(src);
}

/**
 * Delete files
 * @function
 * @param {string[]} deleteArray - Array of paths
 */
function deleteFiles(deleteArray) {
  return new Promise((resolve, reject) => {
    if (deleteArray === null) {
      resolve()
    } else {
      console.log(`Deleting files ${deleteArray}...`);
      del.sync(deleteArray);

      resolve();
    }
  });
}

/**
 * Copy files from temporary folder to root folder
 * @function
 */
function moveFiles() {
  return new Promise((resolve, reject) => {
    console.log('Copying files...');
    copydir('../tmp', '../', (err) => {
      if (err) {
        console.log(err);
        return;
      }
      cd('..');
      del.sync(['tmp']);
      logComplete('Copying files has been completed');

      resolve();
    });
  });
}

/**
 * Output successfully message and run gulp
 * @function
 */
function finish() {
  console.log('Starter has been successfully installed. Good luck '.green +
    emoji.get('wink') + ' \n\u00A9 JustCoded'.green);
  if (Array.prototype.indexOf.call(process.argv, '-d') < 0) {
    exec('gulp');
  }
}


/**
 * Execute all functions synchronically
 * @function
 * @param {Object} conf - Information about git repositary and paths to files to delete
 */
function build(conf, isWPforPug) {
  return new Promise((resolve, reject) => {

    // define source path for WprdPress projects or clean frontend projects (isWP_Path)
    let isWP_Path = isWPforPug == 'WordPress-With-Pug' ? 'assets' : 'src';

    let chain = Promise.resolve();

    for (var i = 0; i < conf.length; i++) {
      // Always delete files from repositories[i].filesToDelete
      // create temporary folder and clone into it
      // move cloned files from temporary folder to root folder
      chain = chain
        .then(deleteFiles.bind(null, conf[i].filesToDelete || null)).catch(e => {
          errorMessage(e);
        })
        .then(git.createTmpFolder).catch(e => {<commit_msg>rewroten comment<commit_after>'use strict';

const colors = require('colors'),
  shell = require('shelljs/global'),
  fs = require('fs'),
  emoji = require('node-emoji'),
  del = require('del'),
  copydir = require('copy-dir'),
  noEmoji = /^win/.test(process.platform);

if (noEmoji) {
  emoji.get = () => '';
}

let config = {},
  configClass = require('./config')({
    fs: fs,
    del: del
  }),
  git = require('./git')({
    folderExists: folderExists,
    logComplete: logComplete,
    del: del,
    emoji: emoji
  }),
  dependencies = require('./dependencies')({
    errorMessage: errorMessage,
    logComplete: logComplete,
    fs: fs
  }),
  vendor = require('./vendor')({
    errorMessage: errorMessage,
    fs: fs
  });

/**
 * Output "Complete" message
 * @function
 */
function logComplete(task) {
  console.log('['.green + task.green + ' ' + emoji.get('white_check_mark') + ' ]\n'.green);
}

/**
 * Output "Error" message
 * @function
 */
function errorMessage(e) {
  console.log(`Error: ${e}`.red);
}

/**
 * Check if the folder exists
 * @function
 */
function folderExists(src) {
  return fs.existsSync(src);
}

/**
 * Delete files
 * @function
 * @param {string[]} deleteArray - Array of paths
 */
function deleteFiles(deleteArray) {
  return new Promise((resolve, reject) => {
    if (deleteArray === null) {
      resolve()
    } else {
      console.log(`Deleting files ${deleteArray}...`);
      del.sync(deleteArray);

      resolve();
    }
  });
}

/**
 * Copy files from temporary folder to root folder
 * @function
 */
function moveFiles() {
  return new Promise((resolve, reject) => {
    console.log('Copying files...');
    copydir('../tmp', '../', (err) => {
      if (err) {
        console.log(err);
        return;
      }
      cd('..');
      del.sync(['tmp']);
      logComplete('Copying files has been completed');

      resolve();
    });
  });
}

/**
 * Output successfully message and run gulp
 * @function
 */
function finish() {
  console.log('Starter has been successfully installed. Good luck '.green +
    emoji.get('wink') + ' \n\u00A9 JustCoded'.green);
  if (Array.prototype.indexOf.call(process.argv, '-d') < 0) {
    exec('gulp');
  }
}


/**
 * Execute all functions synchronically
 * @function
 * @param {Object} conf - Information about git repositary and paths to files to delete
 */
function build(conf, isWPforPug) {
  return new Promise((resolve, reject) => {

    // define source path for WordPress projects or clean frontend projects (isWP_Path)
    let isWP_Path = isWPforPug == 'WordPress-With-Pug' ? 'assets' : 'src';

    let chain = Promise.resolve();

    for (var i = 0; i < conf.length; i++) {
      // Always delete files from repositories[i].filesToDelete
      // create temporary folder and clone into it
      // move cloned files from temporary folder to root folder
      chain = chain
        .then(deleteFiles.bind(null, conf[i].filesToDelete || null)).catch(e => {
          errorMessage(e);
        })
        .then(git.createTmpFolder).catch(e => {
{'fraction_non_alphanumeric': 0.16834461132200032, 'fraction_numerical': 0.001650437365901964, 'mean_word_length': 2.940182054616385, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6496573', 'n_tokens_mistral': 1909, 'n_tokens_neox': 1898, 'n_words': 483}