<commit_before>'use strict';

import co from 'co';
import Prompt from './prompt';
import path from 'path';
import readline from 'readline';
import Metalsmith from 'metalsmith';
import consolidate from 'consolidate';
import each from 'co-each';

var render = consolidate.handlebars.render;
var source = path.resolve(__dirname, '../templates/element/');
var destination = process.cwd();

export default build;

function build(answers) {
  return new Promise(function (resolve, reject) {
    if (answers === null) {
      reject();
    }

    Metalsmith(__dirname)
      .clean(false)
      .source(source)
      .destination(destination)
      .metadata(answers)
      .use(template)
      .build(function (err) {
        if (err) {
          throw err;
        }
        resolve();
      });
  });
}

function template(files, metalsmith, done) {
  var keys = Object.keys(files);
  var metadata = metalsmith.metadata();

  co(function *() {
    yield each(keys, run);
    done();
  });

  function run(key) {<commit_msg>[fixed] passing the correct working dir into Metalsmith<commit_after>'use strict';

import co from 'co';
import Prompt from './prompt';
import path from 'path';
import readline from 'readline';
import Metalsmith from 'metalsmith';
import consolidate from 'consolidate';
import each from 'co-each';

var render = consolidate.handlebars.render;
var source = path.resolve(__dirname, '../templates/element/');
var destination = process.cwd();

export default build;

function build(answers) {
  return new Promise(function (resolve, reject) {
    if (answers === null) {
      reject();
    }

    Metalsmith(source)
      .clean(false)
      .source(source)
      .destination(destination)
      .metadata(answers)
      .use(template)
      .build(function (err) {
        if (err) {
          throw err;
        }
        resolve();
      });
  });
}

function template(files, metalsmith, done) {
  var keys = Object.keys(files);
  var metadata = metalsmith.metadata();

  co(function *() {
    yield each(keys, run);
    done();
  });

  function run(key) {
{'fraction_non_alphanumeric': 0.13686746987951806, 'fraction_numerical': 0.0, 'mean_word_length': 3.119047619047619, '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': '1589360', 'n_tokens_mistral': 647, 'n_tokens_neox': 616, 'n_words': 175}