<commit_before>const fs = require('fs')
const ncp = require('ncp').ncp
const path = require('path')

function writeFile (path, content) {
  fs.writeFile(path, content, 'utf8', error => {
    if (error) {
      throw error
    }
  })
}

function writeFiles (parentDirectory, files) {
  if (!files) {
    return
  }
  if (files.constructor === Array) {
    files.forEach(file => writeFile(path.resolve(parentDirectory, file), ''))
  } else if (files.constructor === Object) {
    Object.keys(files).forEach(name => {
      writeFile(name, files[name])
    })
  }
}

function writeDirectory (parentDirectory, directoryObject) {
  writeFiles(parentDirectory, directoryObject.files)
  if (!directoryObject.directories) return
  Object.keys(directoryObject.directories).forEach(directory => {
    const newParentDirectory = parentDirectory + '/' + directory
    fs.mkdirSync(newParentDirectory)
    writeDirectory(newParentDirectory, directoryObject.directories[directory])
  })
}

function writeFolderConfig (config, callback) {
  const loadFromPath = config.path
  ncp(loadFromPath, process.cwd(), error => {
    if (error) {
      throw error
      callback()
    }
  })
}

function writeRegularConfig (config) {
  return writeDirectory(process.cwd(), config)
}

function write (config, callback) {
  if (config.isDirectory) {
    writeFolderConfig(config, callback)
  } else {
    writeRegularConfig(config)
  }
}

module.exports = {
  write: write
}<commit_msg>Made configWriter test call ncp on all children of loadFromPath<commit_after>const fs = require('fs')
const ncp = require('ncp').ncp
const path = require('path')

function writeFile (path, content) {
  fs.writeFile(path, content, 'utf8', error => {
    if (error) {
      throw error
    }
  })
}

function writeFiles (parentDirectory, files) {
  if (!files) {
    return
  }
  if (files.constructor === Array) {
    files.forEach(file => writeFile(path.resolve(parentDirectory, file), ''))
  } else if (files.constructor === Object) {
    Object.keys(files).forEach(name => {
      writeFile(name, files[name])
    })
  }
}

function writeDirectory (parentDirectory, directoryObject) {
  writeFiles(parentDirectory, directoryObject.files)
  if (!directoryObject.directories) return
  Object.keys(directoryObject.directories).forEach(directory => {
    const newParentDirectory = parentDirectory + '/' + directory
    fs.mkdirSync(newParentDirectory)
    writeDirectory(newParentDirectory, directoryObject.directories[directory])
  })
}

function writeFolderConfig (config, callback) {
  const loadFromPath = config.path
  const folderFiles = fs.readdirSync(loadFromPath)
  let countdown = folderFiles.length
  const beforeCallback = _ => {
    if (--countdown === 0) callback()
  }
  folderFiles.forEach(file => {
    ncp(path.resolve(loadFromPath, file), process.cwd(), error => {
      if (error) {
        throw error
      }
      beforeCallback()
    })
  })
}

function writeRegularConfig (config) {
  return writeDirectory(process.cwd(), config)
}

function write (config, callback) {
  if (config.isDirectory) {
    writeFolderConfig(config, callback)
  } else {
    writeRegularConfig(config)
  }
}

module.exports = {
  write: write
}
{'fraction_non_alphanumeric': 0.1282371294851794, 'fraction_numerical': 0.00093603744149766, 'mean_word_length': 4.017214397496088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1160097', 'n_tokens_mistral': 964, 'n_tokens_neox': 954, 'n_words': 207}