<commit_before>var GLOBAL_KEY = 'app-root-dir';
var _rootDir;

exports.get = function() {
    var dir = global[GLOBAL_KEY];
    if (dir) {
        return dir;
    }

    if (_rootDir === undefined) {
        var fs = require('fs');
        var path = require('path');
        var nm = path.sep + 'node_modules' + path.sep;
        var cwd = process.cwd();
        var pos = cwd.indexOf(nm);
        if (pos !== -1) {
            _rootDir =  cwd.substring(0, pos);
        } else if (fs.existsSync(path.join(cwd, 'package.json'))) {
            _rootDir = cwd;
        } else {
            pos = __dirname.indexOf(nm);
            if (pos === -1) {
                _rootDir = path.normalize(__dirname, '..');
            } else {
                _rootDir = __dirname.substring(0, pos);
            }
        }
    }

    return _rootDir;
};

exports.set = function(dir) {
    global[GLOBAL_KEY] = _rootDir = dir;
};<commit_msg>A little cleanup and fixing call to path.normalize(...) (which only accepts single argument but was given two)<commit_after>var GLOBAL_KEY = 'app-root-dir';
var _rootDir;

exports.get = function() {
    var dir = global[GLOBAL_KEY];
    if (dir) {
        return dir;
    }

    if (_rootDir === undefined) {
        var fs = require('fs');
        var path = require('path');
        var NODE_MODULES = path.sep + 'node_modules' + path.sep;
        var cwd = process.cwd();
        var pos = cwd.indexOf(NODE_MODULES);
        if (pos !== -1) {
            _rootDir =  cwd.substring(0, pos);
        } else if (fs.existsSync(path.join(cwd, 'package.json'))) {
            _rootDir = cwd;
        } else {
            pos = __dirname.indexOf(NODE_MODULES);
            if (pos === -1) {
                _rootDir = path.normalize(path.join(__dirname, '..'));
            } else {
                _rootDir = __dirname.substring(0, pos);
            }
        }
    }

    return _rootDir;
};

exports.set = function(dir) {
    global[GLOBAL_KEY] = _rootDir = dir;
};
{'fraction_non_alphanumeric': 0.14522613065326634, 'fraction_numerical': 0.004020100502512563, 'mean_word_length': 1.8361823361823362, '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': '1589409', 'n_tokens_mistral': 647, 'n_tokens_neox': 645, 'n_words': 146}