<commit_before>module.exports = blake

var resolve = require('path').resolve
  , fstream = require('fstream')
  , fs = require('fs')
  , es = require('event-stream')
  , oven = require('./oven')
  , copy = require('./copy')

function blake () {
  var args = Array.prototype.slice.call(arguments)
    , source = args.shift()
    , target = args.shift()
    , config = args.shift()
    , callback = args.pop()
    , files = args[0] || null
    , paths = require('./paths.js')(source, target, config)
    , templates = require('./templates.js')(paths.templates)
    , views = config.bakeFunctions
  
  var props = {
    templates: templates
  , views: views
  , paths: paths
  }

  if (files.length) {
    return bake(files)
  }

  copy(paths.resources, target, function (err) {
    bake()
  })

  function bake (files) {
    var reader = getReader(files)  
      , writer = oven(props)
    
    reader.pipe(writer)

    writer.on('resume', function () {
      reader.resume()
    })

    writer.on('end', function () {
      if (callback) callback()
    })
  }

  function getReader(files) { 
    if (files) {
      var entries = []
      files.forEach(function (file) {
        entries.push({ path: file })
      })
      return es.readArray(entries)
    }
    
    return fstream.Reader({ path: resolve(source, 'data') })
  }
}
<commit_msg>Tighten files guard<commit_after>module.exports = blake

var resolve = require('path').resolve
  , fstream = require('fstream')
  , fs = require('fs')
  , es = require('event-stream')
  , oven = require('./oven')
  , copy = require('./copy')

function blake () {
  var args = Array.prototype.slice.call(arguments)
    , source = args.shift()
    , target = args.shift()
    , config = args.shift()
    , callback = args.pop()
    , files = args[0] || null
    , paths = require('./paths.js')(source, target, config)
    , templates = require('./templates.js')(paths.templates)
    , views = config.bakeFunctions
  
  var props = {
    templates: templates
  , views: views
  , paths: paths
  }

  if (files && files.length) {
    return bake(files)
  }

  copy(paths.resources, target, function (err) {
    bake()
  })

  function bake (files) {
    var reader = getReader(files)  
      , writer = oven(props)
    
    reader.pipe(writer)

    writer.on('resume', function () {
      reader.resume()
    })

    writer.on('end', function () {
      if (callback) callback()
    })
  }

  function getReader(files) { 
    if (files) {
      var entries = []
      files.forEach(function (file) {
        entries.push({ path: file })
      })
      return es.readArray(entries)
    }
    
    return fstream.Reader({ path: resolve(source, 'data') })
  }
}

{'fraction_non_alphanumeric': 0.16029684601113173, 'fraction_numerical': 0.0007421150278293135, 'mean_word_length': 2.561426684280053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6760239', 'n_tokens_mistral': 873, 'n_tokens_neox': 858, 'n_words': 185}