<commit_before>var path   = require("path"),
    fs     = require("fs"),
    nomnom = require("nomnom"),
    yawp  = require("./yawp"),
    config = {};

// Configuration file
nomnom.option("config", {
    abbr      : "c",
    help      : "Yawp run configuration file",
    default   : ".yawpfile",
    transform : function(loc) {
        if(!loc) return;
        config = JSON.parse(fs.readFileSync(path.resolve(loc), "utf8"));
        return loc;
    }
});

// Json source file
nomnom.option("source", {
    abbr      : "s",
    help      : "Path to JSON source file"
});

// Directory to putput to
nomnom.option("output", {
    abbr      : "o",
    help      : "Path to output file"
});

// Name of initial template
nomnom.option("template", {
    abbr      : "t",
    help      : "Name of main template"
});

// Path to template directory
nomnom.option("template-dir", {
    abbr      : "td",
    help      : "Path to templates directory"
});

function checkConfig(opts) {
    var valid = ["source", "output", "template-dir"];

    valid = valid.every(function(name) {
        var loc;

        if(loc = opts[name]) {
            config[name] = path.resolve(loc);
        } else if(loc = config[name]) {
            config[name] = path.resolve(loc);
        }

        return !!loc;
    });

    return valid;
}

if(checkConfig(nomnom.parse())) {
    yawp.run(config);
}<commit_msg>Will now load yawpfile from default location when no params provided<commit_after>var path       = require("path"),
    fs         = require("fs"),
    nomnom     = require("nomnom"),
    yawp       = require("./yawp"),
    configPath = "./.yawpfile",
    config     = {};

// Configuration file
nomnom.option("config", {
    abbr      : "c",
    help      : "Yawp run configuration file",
    default   : "./.yawpfile",
    transform : function(loc) {
        if(!loc) return;
        configPath = loc; //JSON.parse(fs.readFileSync(path.resolve(loc), "utf8"));
        return loc;
    }
});

// Json source file
nomnom.option("source", {
    abbr      : "s",
    help      : "Path to JSON source file"
});

// Directory to putput to
nomnom.option("output", {
    abbr      : "o",
    help      : "Path to output file"
});

// Name of initial template
nomnom.option("template", {
    abbr      : "t",
    help      : "Name of main template"
});

// Path to template directory
nomnom.option("template-dir", {
    abbr      : "td",
    help      : "Path to templates directory"
});

function checkConfig(opts) {
    var valid = ["source", "output", "template-dir"];

    valid = valid.every(function(name) {
        var loc;

        if(loc = opts[name]) {
            config[name] = path.resolve(loc);
        } else if(loc = config[name]) {
            config[name] = path.resolve(loc);
        }

        return !!loc;
    });

    return valid;
}

config = JSON.parse(fs.readFileSync(path.resolve(configPath), "utf8"));

if(checkConfig(nomnom.parse())) {
    yawp.run(config);
}
{'fraction_non_alphanumeric': 0.16115981119352663, 'fraction_numerical': 0.0010114632501685772, 'mean_word_length': 2.2426229508196722, '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': '6561280', 'n_tokens_mistral': 956, 'n_tokens_neox': 944, 'n_words': 226}