<commit_before>var logger = require('./log');
var argv = require('./arguments').argv;
var git = require('git-rev-sync');
var pjson = require('../package.json');

var getVersionStr = function() {
    process.chdir(__dirname);
    var shorthash = git.short();

    var version = 'teleirc ';
    if (shorthash) {
        version += 'git-' + shorthash + ' (on branch: ' + git.branch() + '), ';
    }

    version += 'npm-' + pjson.version;

    return version;
};

if (argv.version) {
    console.log(getVersionStr());
} else {
    var config = require('./config');

    logger.level = config.logLevel;<commit_msg>Version command: don't explode if we're not in a git repo<commit_after>var logger = require('./log');
var argv = require('./arguments').argv;
var git = require('git-rev-sync');
var pjson = require('../package.json');

var getVersionStr = function() {
    process.chdir(__dirname);

    var shorthash;
    try {
        shorthash = git.short();
    } catch (e) {
        shorthash = null;
    }

    var version = 'teleirc ';
    if (shorthash) {
        version += 'git-' + shorthash + ' (on branch: ' + git.branch() + '), ';
    }

    version += 'npm-' + pjson.version;

    return version;
};

if (argv.version) {
    console.log(getVersionStr());
} else {
    var config = require('./config');

    logger.level = config.logLevel;
{'fraction_non_alphanumeric': 0.1800595238095238, 'fraction_numerical': 0.0, 'mean_word_length': 2.876080691642651, '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': '707845', 'n_tokens_mistral': 446, 'n_tokens_neox': 421, 'n_words': 103}