<commit_before>﻿import grunt = require('grunt');
import path = require('path');
import engines = require('./src/lib/Engine');
import config = require('./src/lib/configs');
import logging = require('./src/lib/logging');
var log = new logging.Log();
var nopt = require('nopt');

// CLI options we care about.
var known = { help: Boolean, version: Boolean, completion: String };
var aliases = { h: '--help', V: '--version', v: '--verbose' };

var args = nopt(known, aliases, process.argv, 2);

process.title = 'itbldz';

global.basedir = process.cwd();
global.relativeDir = __dirname;
global.requireRoot = function (name) {
    return require(__dirname + '/' + name);
};

log.writeln("itbldz", "Environment set up successfully.");
log.verbose.writeln("itbldz", "\tBaseDir\t\t" + global.basedir);
log.verbose.writeln("itbldz", "\tRelativeDir\t" + global.relativeDir);
log.verbose.writeln("itbldz", "\tGruntVersion\t" + grunt.version);

export function itbldz(args) {

    log.writeln("itbldz", "Loading engine...");
    var engine = engines.Engine.get(grunt);

    log.writeln("itbldz", "Loading steps...");
    var currentConfig = config.ConfigurationFileLoaderService.load(grunt);
    log.verbose.writeln("itbldz", "Config loaded: " + JSON.stringify(currentConfig, undefined, 2));

    if (engine) {
        var gruntFile = path.join(global.relativeDir, "src/grunt-utils/gruntfile.js");
        args["gruntfile"] = gruntFile;
        try {
            engine.startUp(currentConfig, (tasks) => {
                (<any>grunt).tasks(tasks, args, () => {
                    log.writeln("itbldz", "Completed successfully");
                    process.exit(0);
                });
            });
        } catch (error) {
            log.error("itbldz", error);
            process.exit(1);
        }
    } else {
        log.error("itbldz", "Missing engine action.");
        process.exit(1);
    }
}
<commit_msg>Print stack error if command line argument "--stack" is set<commit_after>﻿import grunt = require('grunt');
import path = require('path');
import engines = require('./src/lib/Engine');
import config = require('./src/lib/configs');
import logging = require('./src/lib/logging');
var log = new logging.Log();
var nopt = require('nopt');

// CLI options we care about.
var known = { help: Boolean, version: Boolean, completion: String };
var aliases = { h: '--help', V: '--version', v: '--verbose' };

var _args = nopt(known, aliases, process.argv, 2);

process.title = 'itbldz';

global.basedir = process.cwd();
global.relativeDir = __dirname;
global.requireRoot = function (name) {
    return require(__dirname + '/' + name);
};

log.writeln("itbldz", "Environment set up successfully.");
log.verbose.writeln("itbldz", "\tBaseDir\t\t" + global.basedir);
log.verbose.writeln("itbldz", "\tRelativeDir\t" + global.relativeDir);
log.verbose.writeln("itbldz", "\tGruntVersion\t" + grunt.version);

export function itbldz(args) {

    log.writeln("itbldz", "Loading engine...");
    var engine = engines.Engine.get(grunt);

    log.writeln("itbldz", "Loading steps...");
    var currentConfig = config.ConfigurationFileLoaderService.load(grunt);
    log.verbose.writeln("itbldz", "Config loaded: " + JSON.stringify(currentConfig, undefined, 2));

    if (engine) {
        var gruntFile = path.join(global.relativeDir, "src/grunt-utils/gruntfile.js");
        args["gruntfile"] = gruntFile;
        try {
            engine.startUp(currentConfig, (tasks) => {
                (<any>grunt).tasks(tasks, args, () => {
                    log.writeln("itbldz", "Completed successfully");
                    process.exit(0);
                });
            });
        } catch (error) {
            log.error("itbldz", _args.stack ? error.stack : error);
            process.exit(1);
        }
    } else {
        log.error("itbldz", "Missing engine action.");
        process.exit(1);
    }
}

{'fraction_non_alphanumeric': 0.1731312612381197, 'fraction_numerical': 0.0025687130747495505, 'mean_word_length': 3.047817047817048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '279187', 'n_tokens_mistral': 1246, 'n_tokens_neox': 1223, 'n_words': 259}