<commit_before>var FILE = require("file");
var MERGE = require("./merge");
var CONFIG = require("./config");

var parser = new (require("args").Parser)();

parser.help("Builds concatenated and minified scripts from a JavaScript library.");

parser.option("-l", "--list", "list")
    .help("list files to be included in a build")
    .set(true);

parser.arg("config");

parser.helpful();

exports.main = function main(args) {
    
    var options = parser.parse(args);
    
    if (options.args.length < 1) {
        parser.printHelp(options);
        parser.exit(options);
    }
    
    var config = options.args[0];
    if (!FILE.isFile(config)) {
        parser.error(options, "Can't find config file: " + config);
    }
    
    var sections = CONFIG.parse(config);
        
    if (options.list) {
        print();
        var group, separator, ordered;
        for (var section in sections) {
            print(section);
            print(section.replace(/./g, "-"));
            group = sections[section];
            group.root = [FILE.join(FILE.dirname(config), group.root[0])];
            ordered = MERGE.order(group);
            print(ordered.join("\n"));
            print();
        }
    }
    
};<commit_msg>Building with output dir option.<commit_after>var FILE = require("file");
var MERGE = require("./merge");
var CONFIG = require("./config");
var JSMIN = require("./jsmin");

var parser = new (require("args").Parser)();

parser.help("Builds concatenated and minified scripts from a JavaScript library.");

parser.option("-l", "--list", "list")
    .help("list files to be included in a build")
    .set(true);

parser.option("-o", "--outdir", "outdir")
    .help("output directory for scripts")
    .set();

parser.arg("config");

parser.helpful();

exports.main = function main(args) {
    
    var options = parser.parse(args);
    
    if (options.args.length < 1) {
        parser.printHelp(options);
        parser.exit(options);
    }
    
    var config = options.args[0];
    if (!FILE.isFile(config)) {
        parser.error(options, "Can't find config file: " + config);
    }
    
    var sections = CONFIG.parse(config);
        
    var group, separator, ordered, concat, oufile;
    for (var section in sections) {
        group = sections[section];
        group.root = [FILE.join(FILE.dirname(config), group.root[0])];
        if (options.list) {
            ordered = MERGE.order(group);
            print(section);
            print(section.replace(/./g, "-"));
            print(ordered.join("\n"));
            print();
        } else {
            concat = MERGE.concat(group);
            concat = JSMIN.jsmin(concat);
            outfile = section;
            if (options.outdir) {
                outfile = FILE.join(options.outdir, outfile);
            }
            FILE.write(outfile, concat);
        }
    }
    
};
{'fraction_non_alphanumeric': 0.1596931659693166, 'fraction_numerical': 0.0020920502092050207, 'mean_word_length': 2.2602272727272728, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2359921', 'n_tokens_mistral': 857, 'n_tokens_neox': 845, 'n_words': 198}