<commit_before>'use strict';

// includes
var _            = require('lodash');
var q            = require('q');
var cache        = require('memory-cache');

// imports
var utils        = require('./lib/utils.js');
var Build        = require('./lib/build.js');
var config       = utils.requireAndInit('config', __dirname);
var templateInfo = utils.requireAndInit('templateInfo');

// add config to cache
cache.put('config', config);

module.exports = function(tplPath) {
    return templateInfo.getTplPaths(tplPath)
        .then(buildEmails)
        .catch(function(err) {
            utils.logError(1, err);
        });
};

function buildEmails(templates) {
<commit_msg>Fix: save builds to correct directory<commit_after>'use strict';

// includes
var _            = require('lodash');
var cache        = require('memory-cache');
var path         = require('path');

// imports
var utils        = require('./lib/utils.js');
var Build        = require('./lib/build.js');
var templateInfo = utils.requireAndInit('templateInfo');

module.exports = function main(tplPath) {
    return templateInfo.getTplPaths(tplPath)
        .then(initConfig)
        .then(buildEmails)
        .catch(function(err) {
            utils.logError(1, err);
        });
};

function initConfig(templates) {

    // get the root directory based off of the template paths
    var tplPath = path.parse(templates[0]);
    var rootDir = path.resolve(tplPath.dir, '../');

    // initialize the config object and cache it
    var config = utils.requireAndInit('config', rootDir);
    cache.put('config', config);

    return templates;

}

function buildEmails(templates) {

{'fraction_non_alphanumeric': 0.14207650273224043, 'fraction_numerical': 0.0018214936247723133, 'mean_word_length': 2.8594847775175642, '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': '4238226', 'n_tokens_mistral': 473, 'n_tokens_neox': 478, 'n_words': 112}